Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getAssetMap( dir ) {
try {
const dirPath = join( this.props.projectDirectory, dir ),
files = await recursive( dirPath );
return files.reduce( ( carry, filepath ) => {
const filename = basename( filepath ),
[ id ] = filename.split( "." ),
newFilepath = ( dir === DIR_REPORTS ) ? filepath : `${ filepath }?${ Date.now() }`;
carry[ id ] = result( carry, id, []);
carry[ id ].push( newFilepath );
return carry;
}, {});
} catch ( e ) {
// e.g. nothing found
return {};
}
}
return new Promise((resolve) => {
// Clear babel cache directory
rimraf.sync(paths.appBabelCache);
// First, read the current file sizes in build directory.
// This lets us display how much they changed later.
recursive(appBuild, (err, fileNames) => {
const previousSizeMap = (fileNames || [])
.filter(fileName => /\.(js|css)$/.test(fileName))
.reduce((memo, fileName) => {
const contents = fs.readFileSync(fileName);
const key = removeFileNameHash(fileName);
memo[key] = gzipSize(contents);
return memo;
}, {});
// Remove all content but keep the directory so that
// if you're in it, you don't end up in Trash
fs.emptyDirSync(appBuild);
// Start the webpack build
realBuild(previousSizeMap, resolve, argv);
});
return new CancelablePromise((resolve) => {
recursiveReaddir(url, blacklist, (err: any, rawFiles: Array) => {
if (err) {
console.warn(err);
resolve(null);
} else {
// If this is a local source (not a cacheDir call)
if (helpers.next == null) {
helpers.count = filterPathsToJustPlayable(IF.any, rawFiles, true).length;
}
resolve({
data: filterPathsToJustPlayable(filter, rawFiles, true).map((p) => fileURL(p)).sort((a, b) => {
let aFile: any = getFileName(a, false);
if (parseInt(aFile)) {
aFile = parseInt(aFile);
}
let bFile: any = getFileName(b, false);
if (parseInt(aFile)) {
export async function getProjectFiles(rootDir: string = path.join('.', '/'), callback: FilesCallback) {
const { filePushOrder } = await getProjectSettings();
// Load tsconfig
const userConf = getTranspileOptions();
// Read all filenames as a flattened tree
// Note: filePaths contain relative paths such as "test/bar.ts", "../../src/foo.js"
recursive(rootDir, async (err, filePaths) => {
if (err) return callback(err, null, null);
// Filter files that aren't allowed.
const ignorePatterns = await DOTFILE.IGNORE();
// Replace OS specific path separator to common '/' char for console output
filePaths = filePaths.map((name) => name.replace(/\\/g, '/'));
filePaths.sort(); // Sort files alphanumerically
// dispatch with patterns from .claspignore
const filesToPush: string[] = [];
const filesToIgnore: string[] = [];
filePaths.forEach(file => {
if (multimatch(path.relative(rootDir, file), ignorePatterns, { dot: true }).length === 0) {
filesToPush.push(file);
} else {
export async function collectDistFiles(context: CompilationContext): Promise {
const capsuleDir = context.directory;
const compDistRoot = path.resolve(capsuleDir, FIXED_OUT_DIR);
const files = await readdir(compDistRoot);
const readFiles = await Promise.all(
files.map(file => {
return fs.readFile(file);
})
);
return files.map((file, index) => {
const relativePath = path.relative(path.join(capsuleDir, FIXED_OUT_DIR), file);
const pathToFile = path.join(compDistRoot, relativePath);
let test = false;
// Only check js files not d.ts or .map files
if (getExt(relativePath) === 'js') {
// Don't compare extension name, it will surly be different.
// the source is ts / tsx and the dist is js.
test = isTestFile(context.srcTestFiles, relativePath, false);
}
return new Vinyl({
async function findEntryConfigs(entryConfigDir: string): Promise {
const files = await recursive(entryConfigDir);
return files.filter(file => /\.json$/.test(file));
}
async function collectNonDistFiles(context: CompilationContext, ignoreFunction: IgnoreFunction): Promise {
const capsuleDir = context.directory
const compDistRoot = path.resolve(capsuleDir, 'dist')
const fileList = await readdir(capsuleDir, ['*.ts', '*.tsx', ignoreFunction])
const readFiles = await Promise.all(
fileList.map(file => {
return fs.readFile(file)
})
)
const list = fileList.map((file, index) => {
const pathToFile = path.join(compDistRoot, file.split(capsuleDir)[1])
return new Vinyl({
path: pathToFile,
contents: readFiles[index],
base: compDistRoot,
})
})
return list
}, async (res) => {
if (!res || res.length === 0) {
return resolve()
}
const files = []
const prefix = path.dirname(res[0])
for (const path of await readdir(res[0])) {
const size = (await fs.stat(path)).size
files.push({
path: path.substring(prefix.length, path.length),
content: toPull.source(fs.createReadStream(path)),
size: size
})
}
resolve(files)
})
})
)} is under heavy development. API may change between any versions.`
);
if (token) {
accessToken = token;
} else {
const config = getConfig('bottender.config.js', 'messenger');
invariant(config.accessToken, 'accessToken is not found in config file');
accessToken = config.accessToken;
}
const client = MessengerClient.connect(accessToken);
const files = await readdir('assets', ['.*']);
invariant(files.length > 0, 'No files found in `assets` folder.');
files.forEach(print);
let confirm = true;
if (!yes) {
const promptResult = await inquirer.prompt([
{
type: 'confirm',
message: force
? 'Are you sure you want to force upload all assets?'
: 'Is it correct for uploading?',
name: 'confirm',
},
]);