Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function assertIndexJsIntegrity() {
const indexJsPath = project.dir.join('src', 'index.js').asNative;
const indexJsContent = fs.readFileSync(indexJsPath).toString();
if (indexJsContent.indexOf(indexJsNoticeHeader) != -1) {
print(msg.indexJsModified);
const dotIndexJsPath = project.dir.join('src', '.index.js').asNative;
if (fs.existsSync(dotIndexJsPath)) {
print(msg.indexJsBackupPresent);
console.log(
fs
.readFileSync(dotIndexJsPath)
.toString()
.split('\n')
.map(line => `> ${line}`)
.join('\n')
);
const prompt = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
return new Promise((resolve, reject) => {
print(msg.askWhetherToUseBackup);
function assertIndexJsIntegrity() {
const indexJsPath = project.dir.join('src', 'index.js').asNative;
const indexJsContent = fs.readFileSync(indexJsPath).toString();
if (indexJsContent.indexOf(indexJsNoticeHeader) != -1) {
print(msg.indexJsModified);
const dotIndexJsPath = project.dir.join('src', '.index.js').asNative;
if (fs.existsSync(dotIndexJsPath)) {
print(msg.indexJsBackupPresent);
console.log(
fs
.readFileSync(dotIndexJsPath)
.toString()
.split('\n')
.map(line => `> ${line}`)
.join('\n')
);
const prompt = readline.createInterface({
input: process.stdin,
case ProjectType.ANGULAR_CLI:
this._options = {
preset: 'angular-cli',
tuneProject: () => this._tuneAngularCliProject(),
};
print(msg.angularCliDetected);
break;
case ProjectType.CREATE_REACT_APP:
this._options = {
preset: 'create-react-app',
tuneProject: () => this._tuneCreateReactAppProject(),
};
print(msg.createReactAppDetected);
break;
case ProjectType.VUE_CLI:
this._options = {
preset: 'vue-cli',
tuneProject: () => this._tuneVueCliProject(),
};
print(msg.vueCliDetected);
break;
default:
print(msg.unsupportedProjectType);
process.exit(1);
}
}
export default function() {
switch (project.probe.type) {
case ProjectType.ANGULAR_CLI:
buildWith('build', ['--prod=true']);
break;
case ProjectType.CREATE_REACT_APP:
buildWith('build');
break;
case ProjectType.VUE_CLI:
buildWith('build', ['--prod=true']);
break;
default:
print(msg.unsupportedProjectType);
process.exit(1);
}
}
case ProjectType.CREATE_REACT_APP:
this._options = {
preset: 'create-react-app',
tuneProject: () => this._tuneCreateReactAppProject(),
};
print(msg.createReactAppDetected);
break;
case ProjectType.VUE_CLI:
this._options = {
preset: 'vue-cli',
tuneProject: () => this._tuneVueCliProject(),
};
print(msg.vueCliDetected);
break;
default:
print(msg.unsupportedProjectType);
process.exit(1);
}
}
function restoreIndexJs() {
const indexJsPath = project.dir.join('src', 'index.js').asNative;
const dotIndexJsPath = project.dir.join('src', '.index.js').asNative;
if (fs.existsSync(dotIndexJsPath)) {
print(msg.restoringBackup);
fs.copyFileSync(dotIndexJsPath, indexJsPath);
fs.unlinkSync(dotIndexJsPath);
}
}
install() {
print(msg.projectAdapted);
const opts = {
bower: false,
npm: false,
yarn: false,
skipMessage: this.options['skip-install-message'],
skipInstall: this.options['skip-install'],
};
opts[project.pkgManager] = true;
this.installDependencies(opts);
}
initializing() {
this.sourceRoot(path.join(__dirname, 'templates'));
print(msg.welcome);
switch (project.probe.type) {
case ProjectType.ANGULAR_CLI:
this._options = {
preset: 'angular-cli',
tuneProject: () => this._tuneAngularCliProject(),
};
print(msg.angularCliDetected);
break;
case ProjectType.CREATE_REACT_APP:
this._options = {
preset: 'create-react-app',
tuneProject: () => this._tuneCreateReactAppProject(),
};
function backupIndexJs() {
const indexJsPath = project.dir.join('src', 'index.js').asNative;
const dotIndexJsPath = project.dir.join('src', '.index.js').asNative;
print(msg.makingBackup);
fs.copyFileSync(indexJsPath, dotIndexJsPath);
}