Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
require('../config/env');
const path = require('path');
const chalk = require('chalk');
const fs = require('fs-extra');
const webpack = require('webpack');
const config = require('../config/webpack.config.prod');
const paths = require('../config/paths');
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild;
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
const useYarn = fs.existsSync(paths.yarnLockFile);
// Warn and crash if required files are missing
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
process.exit(1);
}
function copyPublicFolder() {
fs.copySync(paths.appPublic, paths.appBuild, {
dereference: true,
filter: file => file !== paths.appHtml,
});
}
// Create the production build and print the deployment instructions.
function build(previousFileSizes) {
console.log('Creating an optimized production build...');
module.exports = async ({ name, tag }) => {
const root = join(process.cwd(), name);
if (fs.existsSync(root)) {
console.log(
`🚨 Aborting: destination folder ${green(
name
)} already exists! Please enter a different folder name.`
);
process.exit(1);
}
console.log(`📦 Creating a new Webiny project in ${green(root)}...`);
fs.ensureDirSync(root);
process.chdir(root);
fs.ensureDirSync("apps");
fs.ensureDirSync("packages");
// Copy project files
function buildEdge(manifest, zip) {
if (!fse.existsSync('./store/edge')) { return false; }
console.log('Building ./extension-edge.zip');
let msPreload = {
backgroundScript: "backgroundScriptsAPIBridge.js",
contentScript: "contentScriptsAPIBridge.js"
}
// Fix options_page
manifest.options_page = manifest.options_ui.page;
delete manifest.options_ui;
// Add ms-proload polyfills
manifest['-ms-preload'] = msPreload;
updateManifestFileInZip(zip, manifest);
zip.addLocalFile('./store/edge/src/backgroundScriptsAPIBridge.js', null);
zip.addLocalFile('./store/edge/src/contentScriptsAPIBridge.js', null);
fse.removeSync('./extension-edge.zip');
exampleFolders.forEach(exampleFolder => {
const exampleConfig = this.loadJsonFile(path.resolve(exampleFolder, EXAMPLE_CONFIG_FILENAME));
if (!fs.existsSync(SHARED_NODE_MODULES_PATH)) {
throw new Error(`The shared node_modules folder for the examples (${SHARED_NODE_MODULES_PATH}) is missing.\n` +
`Perhaps you need to run "yarn example-use-npm" or "yarn example-use-local" to install the dependencies?`);
}
// Link the node modules - requires admin access (on Windows) because it adds symlinks
const destinationNodeModules = path.resolve(exampleFolder, 'node_modules');
fs.ensureSymlinkSync(SHARED_NODE_MODULES_PATH, destinationNodeModules);
const boilerPlateType = exampleConfig.projectType || 'cli';
const boilerPlateBasePath = path.resolve(BOILERPLATE_BASE_PATH, boilerPlateType);
// Copy the boilerplate specific files
BOILERPLATE_PATHS[boilerPlateType].forEach(filePath => this.copyFile(boilerPlateBasePath, exampleFolder, filePath));
// Copy the boilerplate common files
BOILERPLATE_PATHS.common.forEach(filePath => this.copyFile(BOILERPLATE_COMMON_BASE_PATH, exampleFolder, filePath));
pipe.on('close', function() {
var checkPath = path.join(destDir, 'src', 'github.com', 'example_cc');
t.equal(fs.existsSync(checkPath), true, 'The tar.gz file produced by Chain.packageChaincode() has the "src/github.com/example_cc" folder');
});
});
function deleteFolderRecursive(path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function (file, index) {
var curPath = path + '/' + file;
if (fs.lstatSync(curPath).isDirectory()) {
testUtils.deleteFolderRecursive(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
}
testUtils.deleteFolderRecursive = deleteFolderRecursive;
public make(): void {
const adapterFile: string = `${process.env.CORE_PATH_CACHE}/webhooks.json`;
if (!existsSync(adapterFile)) {
ensureFileSync(adapterFile);
}
this.database = lowdb(new FileSync(adapterFile));
this.database.defaults({ webhooks: [] }).write();
}
private static resolveFilePath(refPath: string, httpFilePath: string): string | null {
if (path.isAbsolute(refPath)) {
return fs.existsSync(refPath) ? refPath : null;
}
let absolutePath;
const rootPath = getWorkspaceRootPath();
if (rootPath) {
absolutePath = path.join(Uri.parse(rootPath).fsPath, refPath);
if (fs.existsSync(absolutePath)) {
return absolutePath;
}
}
absolutePath = path.join(path.dirname(httpFilePath), refPath);
if (fs.existsSync(absolutePath)) {
return absolutePath;
}
constructor(options: FileAppStoreOptions) {
this.appDir = options.appDir
if (!fs.existsSync(this.appDir)) {
throw new Error("Could not find path: " + this.appDir)
}
const stat = fs.statSync(this.appDir)
if (!stat.isDirectory()) {
this.appDir = path.dirname(this.appDir)
}
this.env = options.env
this.buildDir = options.buildDir || path.join(this.appDir, ".fly", "build", this.env)
if (!fs.existsSync(this.buildDir)) {
fs.mkdirpSync(this.buildDir)
}
this.release = {
app: options.app_name || this.appDir,
const initLocales = () => {
let langId = getPreference('langId');
if (!fsExtra.existsSync(path.resolve(__dirname, `${langId}.json`))) {
langId = 'en';
}
locales = fsExtra.readJsonSync(path.resolve(__dirname, `${langId}.json`));
};