How to use the backfill-config.outputFolderAsArray function in backfill-config

To help you get started, we’ve selected a few backfill-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / backfill / packages / backfill / src / audit.ts View on Github external
changedFilesOutsideScope = [];
  changedFilesInsideScope = [];

  logger.info("Running in AUDIT mode");
  logger.info(`[audit] Watching file changes in: ${repositoryRoot}`);
  logger.info(`[audit] Backfill will cache folder: ${outputFolder}`);

  // Define globs
  const ignoreGlobs = addGlobstars([
    ".git",
    ".cache",
    logFolder,
    internalCacheFolder
  ]);

  const cacheFolderGlob = outputFolderAsArray(outputFolder).map(folder =>
    path.posix.join("**", folder, "**")
  );

  watcher = chokidar
    .watch(hashGlobs, {
      ignored: ignoreGlobs,
      cwd: repositoryRoot,
      persistent: true,
      ignoreInitial: true,
      followSymlinks: false,
      usePolling: true
    })
    .on("all", (event, filePath) => {
      const logLine = `${filePath} (${event})`;
      logger.silly(`[audit] File change: ${logLine}`);
github microsoft / backfill / packages / backfill / src / commandRunner.ts View on Github external
return async (): Promise => {
    const parsedBuildCommand = buildCommand.join(" ");

    if (!parsedBuildCommand) {
      throw new Error("Command not provided");
    }

    // Clear outputFolder to guarantee a deterministic cache
    if (clearOutputFolder) {
      await Promise.all(
        outputFolderAsArray(outputFolder).map(folder => fs.remove(folder))
      );
    }

    // Set up runner
    logger.profile("buildCommand:run");
    const runner = execa(parsedBuildCommand, {
      shell: true,
      ...(process.env.NODE_ENV !== "test" ? { stdio: "inherit" } : {})
    });

    return (
      runner
        // Add build time to the performance logger
        .then(() => {
          logger.setTime("buildTime", "buildCommand:run");
        })
github microsoft / backfill / packages / cache / src / NpmCacheStorage.ts View on Github external
const { npmPackageName, registryUrl, npmrcUserconfig } = this.options;

    const temporaryNpmOutputFolder = path.join(
      this.internalCacheFolder,
      "npm",
      hash,
      "upload"
    );

    // Create package.json file
    fs.outputJSONSync(path.join(temporaryNpmOutputFolder, "package.json"), {
      name: npmPackageName,
      version: `0.0.0-${hash}`
    });

    outputFolderAsArray(outputFolder).forEach(folder => {
      fs.copySync(folder, path.join(temporaryNpmOutputFolder, folder));
    });

    // Upload package
    try {
      await execa(
        "npm",
        [
          "publish",
          "--registry",
          registryUrl,
          "--loglevel",
          "error",
          ...(npmrcUserconfig ? ["--userconfig", npmrcUserconfig] : [])
        ],
        {
github microsoft / backfill / packages / cache / src / LocalCacheStorage.ts View on Github external
protected async _put(
    hash: string,
    outputFolder: string | string[]
  ): Promise {
    const localCacheFolder = this.getLocalCacheFolder(hash);

    await Promise.all(
      outputFolderAsArray(outputFolder).map(async folder => {
        const outputFolderInCache = path.join(localCacheFolder, folder);

        await fs.mkdirp(outputFolderInCache);
        await fs.copy(folder, outputFolderInCache);
      })
    );
  }
}
github microsoft / backfill / packages / hasher / src / index.ts View on Github external
public async hashOfOutput(): Promise {
    const outputFolderGlob = outputFolderAsArray(this.outputFolder).map(
      p => `${p}/**`
    );

    return generateHashOfFiles(this.packageRoot, outputFolderGlob);
  }
}
github microsoft / backfill / packages / cache / src / NpmCacheStorage.ts View on Github external
],
          { stdout: "inherit" }
        );
      } catch (error) {
        fs.removeSync(temporaryNpmOutputFolder);

        if (error.stderr.toString().indexOf("ETARGET") > -1) {
          return false;
        } else {
          throw new Error(error);
        }
      }
    }

    await Promise.all(
      outputFolderAsArray(outputFolder).map(async folder => {
        const locationInCache = path.join(
          packageFolderInTemporaryFolder,
          folder
        );

        if (!fs.pathExistsSync(locationInCache)) {
          return;
        }

        await fs.mkdirp(folder);
        await fs.copy(path.join(locationInCache, folder), folder);
      })
    );

    return true;
  }
github microsoft / backfill / packages / cache / src / AzureBlobCacheStorage.ts View on Github external
protected async _put(
    hash: string,
    outputFolder: string | string[]
  ): Promise {
    const blobClient = createBlobClient(
      this.options.connectionString,
      this.options.container,
      hash
    );

    const blockBlobClient = blobClient.getBlockBlobClient();

    const outputFolders = outputFolderAsArray(outputFolder);
    const tarStream = tar.create({ gzip: false }, outputFolders);

    await blockBlobClient.uploadStream(
      tarStream,
      uploadOptions.bufferSize,
      uploadOptions.maxBuffers
    );
  }
}
github microsoft / backfill / packages / cache / src / LocalCacheStorage.ts View on Github external
protected async _fetch(
    hash: string,
    outputFolder: string | string[]
  ): Promise {
    const localCacheFolder = this.getLocalCacheFolder(hash);

    if (!fs.pathExistsSync(localCacheFolder)) {
      return false;
    }

    await Promise.all(
      outputFolderAsArray(outputFolder).map(async folder => {
        const locationInCache = path.join(localCacheFolder, folder);

        if (!fs.pathExistsSync(locationInCache)) {
          return;
        }

        await fs.mkdirp(folder);
        await fs.copy(locationInCache, folder);
      })
    );

    return true;
  }

backfill-config

Backfill Config

MIT
Latest version published 12 months ago

Package Health Score

68 / 100
Full package analysis

Similar packages