Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'gulp-json-editor' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
gulp.task('build-replace', () => {
// Copy file config dev or production
const conf = process.argv[3] ? 'index' : 'production';
// Copy config production
gulp.src([`src/config/${conf}.js`]).pipe(babel()).pipe(rename('index.js')).pipe(gulp.dest(`${dist_server}/config`));
// Copy views
gulp.src(['src/views/**/*.*', '!src/views/**/*.js']).pipe(minify({ minify: true, collapseWhitespace: true, conservativeCollapse: true, minifyCSS: true })).pipe(gulp.dest(`${dist_server}/views`));
// Copy assets
gulp.src(['src/assets/**/*']).pipe(gulp.dest(`${dist_server}/assets`));
// Copy *.yaml
gulp.src(['src/**/*.yaml']).pipe(gulp.dest(dist_server));
// Copy swagger/ui
gulp.src([`src/lib/swagger/ui/*`]).pipe(gulp.dest(dist_swagger));
// package.json
gulp.src("package.json").pipe(jeditor((json) => {
delete json.devDependencies;
json.scripts = {
"start": `node server/app.js`,
"simple": `npm stop && pm2 start ${pm2_simple} --env production`,
"cluster": `npm stop && pm2 start ${pm2_cluster} --env production`,
"stop": `pm2 delete ${pm2_simple} ${pm2_cluster}`
};
return json;
})).pipe(gulp.dest(dist));
// Copy pm2 files
gulp.src([pm2_simple, pm2_cluster]).pipe(gulp.dest(dist));
// If exits client folder, then copy current client
if (fs.existsSync(`${dist}/client`)) {
gulp.src(['client/**/*']).pipe(gulp.dest(dist_client));
} else {
// If not exists client folder, then copy default client
function publishGit() {
return merge(
gulp.src('package.json').pipe(jsonEditor((json) => {
const name = { name: `${json.name}${config.target.prefix ? ('-' + config.target.prefix) : ''}`}
return Object.assign({}, json, config.target.packageRewrite, ...name);
})),
gulp.src([config.base.dist + '/**', ...config.base.static]),
).pipe(
ghPages({
branch: config.target.branch,
cacheDir: config.base.publishCache,
push: true,
}),
);
}
gulp.task('transifex:prepare', () => {
if (transifexClient) {
gulp.src('./localization/react-intl/**/*').pipe(jsonEditor((inputJson) => {
const outputJson = {};
inputJson.forEach((entry) => {
outputJson[entry.id] = entry.defaultMessage;
});
return outputJson;
})).pipe(gulp.dest('./localization/transifex/'));
}
});
}, () => {
takerInst.src(variables.paths.versionsToBump, variables.srcConfig)
.pipe(jeditor({version: newVersion}))
.pipe(takerInst.dest('./', {cwd: variables.rootDir}));
return commitIt(takerInst, newVersion, this.store, resolve);
});
}));
public packagePreparePackageFile (): NodeJS.ReadWriteStream {
return gulp
.src('./package.json')
.pipe(jsonEditor((json: Record) => {
const dependencies: Record | undefined = json.dependencies
const peerDependencies: Record | undefined = json.peerDependencies
json.private = false
json.sideEffects = false
json.main = 'index.js'
json.types = 'index.d.ts'
json.author = pkg.author
json.homepage = pkg.homepage
json.repository = pkg.repository
if (dependencies) {
json.dependencies = Object.keys(dependencies).reduce>((obj, name) => {
if (name in packages) {
obj[name] = '^' + (packages as any)[name].version
}
return obj
const copyMainResource = () => {
const resource = src(path.join(__dirname, '../app/main/resource/**'))
.pipe(dest(path.join(__dirname, '../lib/resource')));
const pkg = src(path.join(__dirname, '../package.json'))
.pipe(jeditor({
main: './main.js',
}))
.pipe(dest(path.join(__dirname, '../lib')));
const license = src(path.join(__dirname, '../LICENSE'))
.pipe(dest(path.join(__dirname, '../lib')));
const assets = src(path.join(__dirname, ('../assets/**')))
.pipe(dest(path.join(__dirname, '../lib/assets')));
return merge(
resource,
pkg,
license,
assets,
);
};
copyMainResource.displayName = 'after:buildMain';
gulp.task('need-categories', (callback) => {
return request(endpoints.needCategories)
.pipe(source(`${config.paths.generatedData}need-categories.js`))
.pipe(streamify(jeditor(function (data) {
return data
.sortAsc('value')
})))
.pipe(replace('[', 'export const categories = ['))
.pipe(gulp.dest('./'))
})
gulp.task('dist:copypkg', function () {
let txt = gulp.src(['./README.md', './LICENSE'])
.pipe(plumber(errorHandler('dist:copypkg (txt)')))
.pipe(gulp.dest('./dist'));
let pkg = gulp.src('./package.json')
.pipe(jsoneditor(function (json) {
delete json.scripts;
delete json.devDependencies;
delete json.semistandard;
return json;
}))
.pipe(plumber(errorHandler('dist:copypkg (pkg)')))
.pipe(gulp.dest('./dist'));
return merge(txt, pkg);
});
export const version = () =>
gulp.src(`${config.in}package.json`, { base: `${config.in}` })
.pipe(jeditor({
"version": `${moment.utc().format("YYYYMMDD.H.m")}`
}))
.pipe(gulp.dest(config.out));
gulp.task("copy-package", callback => {
return gulp.src("./package.json")
.pipe(jeditor((pkgjson) => {
delete pkgjson.scripts.sdk;
return pkgjson;
}))
.pipe(gulp.dest("./dist"));
});