Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var version = find.findSync("version", ".", "package.json").then(s => {
try {
var versionLine = s["package.json"].line[0];
var versionSplit = versionLine.split('"');
var version = versionSplit[3];
// to update client version in code
var options2 = {
files: ["./src/app/constants.ts"],
from: [/clientVersion.*/g],
to: "clientVersion = '" + version + "';"
};
replace.sync(options2);
} catch (e) {
console.error('Error occurred updating version:', e);
}
});
files: typingFile,
from: [
/\r?\n?^.*import.*\{.*\}.*from.*\;/gm,
/\r?\nimport \* as moment from 'moment-timezone';/g,
/^.*export.*\{.*\}.*from.*\;/gm,
/^.*export.*\{.*\};$/gm,
/^.*\/\/\/\s*\/gm,
/(\r?\n\s*\/\*\*\s*\r?\n([^\*]|(\*(?!\/)))*\*\/)?\r?\n\s*private\s.*;/gm, // replace line with private and also preceding lines with jsdoc comments
// /^\s*private\s.*;/gm, // original replacing private did not replace p
/\r\n\r\n/g,
/\n\n/g,
/export declare/g,
],
to: '',
};
replace.sync(options);
}
try {
var nameLine = s["package.json"].line[0];
var nameSplit = nameLine.split('"');
var name = nameSplit[3];
var newName = name.indexOf("alt") >= 0 ? "nakedobjects.spa" : "nakedobjects.alt.spa";
var regex = new RegExp(name, "g");
var options = {
files: ["package.json"],
from: regex,
to: newName
};
replace.sync(options);
} catch (e) {
console.error('Error occurred updating name:', e);
}
});
function changeLocalUrl(themeLocalUrl) {
if(themeLocalUrl == "") {
console.log(chalk.magenta.bold('Local URL was not chnanged.'));
return;
}
const options = {
files: 'webpack.config.js',
from: /proxy: .{1,}/g,
to: `proxy:: "${themeLocalUrl}"`,
};
try {
const changes = replace.sync(options);
console.log(chalk.magenta.bold('Local URL updated in: ') + ('config.js'));
}
catch (error) {
console.error('Error occurred:', error);
}
}
function preProcessRunningJs() {
var options = {
files: "running.js",
from: "[DATE]",
to: "[" + "OWASP Mobile Security Testing Guide: " + tag + "]"
};
try {
const changes = replace.sync(options);
console.log("Modified files:", changes.join(", "));
} catch (error) {
console.error("Error occurred:", error);
}
}
function replaceVersionLink(fromVersion, toVersion, files) {
const link = `\/?${fromVersion}/`;
const reg = new RegExp(link, 'g');
const options = {
files: files,
//Replacement to make (string or regex)
from: reg,
to: `/archived/${toVersion}/`,
};
let changedFiles = replace.sync(options);
console.log(`Modified files:\n${changedFiles.join('\n')}`);
}
console.log('..Updating src/version.js');
const versionFile = path.join(__dirname, '../src/version.js');
const newContent = `export default '${newVersion}';\n`;
fs.writeFileSync(versionFile, newContent);
console.log('..Updating package.json');
replace.sync({
files: [path.join(__dirname, '..', 'package.json')],
from: `"version": "${currentVersion}"`,
to: `"version": "${newVersion}"`,
});
replace.sync({
files: [path.join(__dirname, '..', 'README.md')],
from: `places.js@${currentVersion}`,
to: `places.js@${newVersion}`,
});
const optionsOldProd = {
files:[
'src/environments/environment.prod.ts',
'src/environments/environment.ts'
],
from: /production: (.*)/g,
to: "production: '{PRODUCTION}',",
allowEmptyPaths: false,
};
try {
let changeOldYearFiles = replace.sync(optionsOldYear);
let changeNewYearFiles = replace.sync(optionsNewYear);
let changeOldProdFiles = replace.sync(optionsOldProd);
let changeProdFiles = replace.sync(optionsNewProd);
let changeDevFiles = replace.sync(optionsNewDev);
console.log('Environment variables have been set');
}
catch (error) {
console.error('Error occurred:', error);
throw error
}
].reduce((filesToCompile, item) => {
let itemPath = ''
if (typeof item === 'string') {
itemPath = item
} else if (typeof item === 'object' && Array.isArray(item)) {
itemPath = item[0]
} else if (typeof item === 'object' && typeof item.handler === 'string') {
itemPath = item.handler
}
if (itemPath) {
const srcDir = nuxtConfigFile.srcDir ? (path.relative(rootDir, nuxtConfigFile.srcDir)).replace('now_compiled', '.') : '.'
const resolvedPath = path.resolve(rootDir, itemPath.replace(/^[@~]\//, `${srcDir}/`).replace(/\.ts$/, ''))
if (fs.existsSync(`${resolvedPath}.ts`)) {
filesToCompile.push(resolvedPath)
replaceInFile.sync({
files: path.resolve(rootDir, 'now_compiled/nuxt.config.js'),
from: new RegExp(`(?<=['"\`])${itemPath}(?=['"\`])`, 'g'),
to: itemPath.replace(/\.ts$/, '')
})
}
}
return filesToCompile
}, [] as string[])
await Promise.all(