How to use revJson method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

gulpfile.js

Source:gulpfile.js Github

copy

Full Screen

1// 修复 gulp-uglify except不可用的bug,需要改成reserved2var config = require('./config');3var gulp = require('gulp');4var minifyCss = require('gulp-clean-css'); //- 压缩CSS为一行;5var htmlmin = require('gulp-htmlmin');6var rev = require('gulp-rev'); //- 对文件名加MD5后缀7var revCollector = require('gulp-rev-collector'); //- 路径替换8var clean = require('gulp-clean');9var uglify = require('gulp-uglify')10 //串行执行任务11var runSequence = require('run-sequence');12//同个task下合并多个步骤13var mergeStream = require('merge-stream');14//图片压缩相关15var imagemin = require('gulp-imagemin');16//cach17var cache = require('gulp-cache');18//错误抛出的补丁->防止异常情况下停止程序19var plumber = require('gulp-plumber');2021var handleErrors = function(error) {22 //继续监听23 console.log("~~~错误:" + error);24};25//情况以前目录26gulp.task('clean', function() {27 return gulp.src([28 config.clean.src29 ])30 //异常处理的补丁31 .pipe(plumber({32 errorHandler: handleErrors33 }))34 .pipe(clean({35 force: true36 }));37});38//处理需要md5签名的图片39gulp.task('dealMd5Img', function() {40 //排除html/**/img下面的41 //排除/libs/**/img下的42 return gulp.src([config.img.src, '!' + config.html.img.src, '!' + config.libs.img.src])43 .pipe(plumber({44 errorHandler: handleErrors45 }))46 .pipe(cache(imagemin({47 optimizationLevel: 3,48 progressive: true,49 interlaced: true50 })))51 .pipe(rev())52 .pipe(gulp.dest(config.img.dest))53 .pipe(rev.manifest(config.img.revJson, {54 //不合并55 merge: false56 }))57 //因为已经进入了json了,所以默认./就行58 .pipe(gulp.dest('./'));59});60//处理其他的图片-除去上面压缩后的61gulp.task('dealOtherImg', function() {62 //html/**/img下面的63 ///libs/**/img下的64 var htmlImg = gulp.src([config.html.img.src])65 .pipe(plumber({66 errorHandler: handleErrors67 }))68 .pipe(cache(imagemin({69 optimizationLevel: 3,70 progressive: true,71 interlaced: true72 })))73 .pipe(gulp.dest(config.html.img.dest));74 var libsImg = gulp.src([config.libs.img.src])75 .pipe(plumber({76 errorHandler: handleErrors77 }))78 .pipe(cache(imagemin({79 optimizationLevel: 3,80 progressive: true,81 interlaced: true82 })))83 .pipe(gulp.dest(config.libs.img.dest));8485 return mergeStream(htmlImg, libsImg);86});87//压缩并处理 json-这个是json文件夹下面的配置,只处理这个文件夹88gulp.task('dealJSON', function() {89 return gulp.src([config.json.src])90 .pipe(plumber({91 errorHandler: handleErrors92 }))93 .pipe(cache(imagemin({94 optimizationLevel: 3,95 progressive: true,96 interlaced: true97 })))98 .pipe(rev())99 .pipe(gulp.dest(config.json.dest))100 .pipe(rev.manifest(config.json.revJson, {101 //不合并102 merge: false103 }))104 //因为已经进入了json了,所以默认./就行105 .pipe(gulp.dest('./'));106});107//处理css108gulp.task('dealCss', function() {109 //- 需要处理的css文件,先替换里面的图片,然后再压缩md5签名110 //排除libs下的css111 return gulp.src([config.rev.revJson, config.css.src])112 .pipe(plumber({113 errorHandler: handleErrors114 }))115 .pipe(revCollector())116 .pipe(minifyCss()) //- 压缩处理成一行117 .pipe(rev()) //- 文件名加MD5后缀118 .pipe(gulp.dest(config.css.dest)) //- 输出文件本地,*号会自动输出119 .pipe(rev.manifest(config.css.revJson, {120 merge: false121 }))122 .pipe(gulp.dest('./')); //- 将 rev-manifest.json 保存到 rev 目录内123});124//先处理框架第三方不会依赖其它脚本的文件,排除seajs的配置,排除cacheConfig配置125//先处理的css,所以core里就算有引用css也没问题126gulp.task('dealCoreJs', function() {127 //- 需要处理的css文件,先替换里面的图片,然后再压缩md5签名128 return gulp.src([config.rev.revJson, config.js.coreJs.src, '!' + config.js.seaConfigJs.src, '!' + config.js.cacheConfigJs.src])129 .pipe(plumber({130 errorHandler: handleErrors131 }))132 .pipe(revCollector())133 .pipe(uglify({134 //mangle: true,//类型:Boolean 默认:true 是否修改变量名135 mangle: {136 reserved: ['require', 'exports', 'module', '$']137 } //排除混淆关键字138 }))139 .pipe(rev())140 .pipe(gulp.dest(config.js.coreJs.dest))141 .pipe(rev.manifest(config.js.coreJs.revJson, {142 merge: false143 }))144 .pipe(gulp.dest('./'));145});146//再处理业务js,会依赖于以上的两种js147//排除业务处理的config148gulp.task('dealBizlogicJs', function() {149 //- 需要处理的css文件,先替换里面的图片,然后再压缩md5签名150 return gulp.src([config.rev.revJson, config.js.bizlogicJs.src, '!' + config.js.bizConfigJs.src])151 .pipe(plumber({152 errorHandler: handleErrors153 }))154 .pipe(revCollector())155 .pipe(uglify({156 //mangle: true,//类型:Boolean 默认:true 是否修改变量名157 mangle: {158 reserved: ['require', 'exports', 'module', '$']159 } //排除混淆关键字160 }))161 .pipe(rev())162 .pipe(gulp.dest(config.js.bizlogicJs.dest))163 .pipe(rev.manifest(config.js.bizlogicJs.revJson, {164 merge: false165 }))166 .pipe(gulp.dest('./'));167});168169//再处理seajs的配置,或者是项目中的配置170gulp.task('dealSeaConfig', function() {171 //- 需要处理的css文件,先替换里面的图片,然后再压缩md5签名172 return gulp.src([config.rev.revJson, config.js.seaConfigJs.src])173 .pipe(plumber({174 errorHandler: handleErrors175 }))176 .pipe(revCollector())177 .pipe(uglify({178 //mangle: true,//类型:Boolean 默认:true 是否修改变量名179 mangle: {180 reserved: ['require', 'exports', 'module', '$']181 } //排除混淆关键字182 }))183 .pipe(rev())184 .pipe(gulp.dest(config.js.seaConfigJs.dest))185 .pipe(rev.manifest(config.js.seaConfigJs.revJson, {186 //允许合并以前的bizConfig187 //这里注意,如果是通过路径找到的json,则merge有用,否则merge并没有用188 merge: true189 }))190 .pipe(gulp.dest('./'));191});192//处理bizConfigJs的配置,或者是项目中的配置193//排除业务设置的路径194gulp.task('dealBizConfig', function() {195 //- 需要处理的css文件,先替换里面的图片,然后再压缩md5签名196 return gulp.src([config.rev.revJson, config.js.bizConfigJs.src])197 .pipe(plumber({198 errorHandler: handleErrors199 }))200 .pipe(revCollector())201 .pipe(uglify({202 //mangle: true,//类型:Boolean 默认:true 是否修改变量名203 mangle: {204 reserved: ['require', 'exports', 'module', '$']205 } //排除混淆关键字206 }))207 .pipe(rev())208 .pipe(gulp.dest(config.js.bizConfigJs.dest))209 .pipe(rev.manifest(config.js.bizConfigJs.revJson, {210 merge: true211 }))212 .pipe(gulp.dest('./'));213});214//cacheController->控制引入seaConfig215gulp.task('dealCacheConfigJs', function() {216 //- 需要处理的css文件,先替换里面的图片,然后再压缩md5签名217 return gulp.src([config.rev.revJson, config.js.cacheConfigJs.src])218 .pipe(plumber({219 errorHandler: handleErrors220 }))221 .pipe(revCollector())222 .pipe(uglify({223 //mangle: true,//类型:Boolean 默认:true 是否修改变量名224 mangle: {225 reserved: ['require', 'exports', 'module', '$']226 } //排除混淆关键字227 }))228 .pipe(rev())229 .pipe(gulp.dest(config.js.cacheConfigJs.dest))230 .pipe(rev.manifest(config.js.cacheConfigJs.revJson, {231 merge: true232 }))233 .pipe(gulp.dest('./'));234});235//处理html236gulp.task('dealHtml', function() {237 //- 需要处理的css文件,先替换里面的图片,然后再压缩md5签名238 return gulp.src([config.rev.revJson, config.html.src])239 .pipe(plumber({240 errorHandler: handleErrors241 }))242 .pipe(revCollector())243 .pipe(htmlmin({244 collapseWhitespace: true,245 collapseBooleanAttributes: true,246 removeComments: true,247 removeEmptyAttributes: true,248 removeScriptTypeAttributes: true,249 removeStyleLinkTypeAttributes: true,250 //有时候有这个配置会出错(当代码作为示例显示时),所以脚本和css只压缩单独的文件251 minifyJS: true,252 minifyCSS: true253 })) //压缩254 .pipe(gulp.dest(config.html.dest));255});256//处理其它,除去img,css,html,js,以外的,单独包括.project文件257gulp.task('dealOthers', function() {258 //出去svn259 return gulp.src([config.other.src, config.other.project.src, '!' + config.js.coreJs.src, '!' + config.js.bizlogicJs.src, '!' + config.css.src, '!' + config.html.src, '!' + config.json.src, '!' + config.img.src, '!' + config.other.svn.src, '!' + config.other.settings.src])260 .pipe(plumber({261 errorHandler: handleErrors262 }))263 .pipe(gulp.dest(config.other.dest));264});265266// 看守267gulp.task('watch', function() {268269 console.log("路径:" + config.src + '/gulpWatch.json');270 // 看守所有位在 dist/ 目录下的档案,一旦有更动,便进行重整271 // gulp.watch([config.src+'/gulpWatch.json']).on('change', function(file) {272 // console.log("改动");273 // });274 gulp.watch(config.src + '/gulpWatch.json', ['default']);275276});277//压缩框架文件,仅仅压缩278gulp.task('MiniCoreJs', function() {279 //- 需要处理的css文件,先替换里面的图片,然后再压缩md5签名280 return gulp.src([config.js.coreJs.src])281 .pipe(plumber({282 errorHandler: handleErrors283 }))284 //.pipe(revCollector())285 .pipe(uglify({286 //mangle: true,//类型:Boolean 默认:true 是否修改变量名287 mangle: {288 reserved: ['require', 'exports', 'module', '$']289 } //排除混淆关键字290 }))291 //.pipe(rev())292 .pipe(gulp.dest(config.js.coreJs.dest))293// .pipe(rev.manifest(config.js.coreJs.revJson, {294// merge: false295// }))296// .pipe(gulp.dest('./'));297});298gulp.task('default', function(callback) {299 if(!config.isMiniJs){300 runSequence('clean', 'dealMd5Img', 'dealOtherImg', 'dealJSON', 'dealCss', 'dealCoreJs', 'dealBizlogicJs', 'dealSeaConfig', 'dealBizConfig', 'dealCacheConfigJs', 'dealHtml', 'dealOthers',301 callback);302 }else{303 runSequence('MiniCoreJs',304 callback);305 }306 ...

Full Screen

Full Screen

config.js

Source:config.js Github

copy

Full Screen

1/**2 * 作者: dailc3 * 时间: 2016-06-22 4 * 描述: gulp的一些配置,包括路径,项目层级5 * 6 */7(function() {8 //项目path,默认为''代表不使用项目path9 //示例/testproject10 //var projectPath = '/testDemo'11 var projectPath = '/showcase.dcloud.rayapp'12 var src = './src' + projectPath;13 var dest = './build' + projectPath;14 var rev = './rev' + projectPath;15 var isMiniJs = false;16 //定义的一些文件编译和输出路径,可以不用管太多17 module.exports = {18 //如果src前有**,目录会自动补齐19 src:src,20 dest:dest,21 rev:rev,22 css: {23 //所有需要编译的css24 src: src + '/**/css/**/*.css',25 //输出目录26 dest: dest + "",27 //json目录28 revJson: rev + "/rev-manifest-css.json"29 },30 js: {31 src: src + '/js/**/*.js',32 coreJs: {33 src: src + '/**/js/core/**/*.js',34 dest: dest + "",35 revJson: rev + "/rev-manifest-coreJs.json"36 },37 bizlogicJs: {38 src: src + '/**/js/bizlogic/**/*.js',39 dest: dest + "",40 revJson: rev + "/rev-manifest-bizlogicJs.json"41 },42 //seaConfig-以下三个config会合并43 seaConfigJs: {44 src: src + '/**/sea.config.js',45 dest: dest + "",46 revJson: rev + "/rev-manifest-config.json"47 },48 //业务处理的config ->包括自定义sea别名等49 bizConfigJs: {50 src: src + '/**/bizlogic/config/seaBizConfig.js',51 dest: dest + "",52 revJson: rev + "/rev-manifest-config.json"53 },54 //cacheController->控制引入seaConfig55 cacheConfigJs: {56 src: src + '/**/cacheControl.config.js',57 dest: dest + "",58 revJson: rev + "/rev-manifest-config.json"59 }60 },61 //默认图片只处理img目录下的,其它目录下的由于路径问题不好替换62 //所以img文件夹下请别放其它文件63 //由于有些项目直接在html里又有img,所以构建时得单独排除那一部分64 img: {65 jpg: {66 src: src + '/img/**/*.jpg'67 },68 png: {69 src: src + '/img/**/*.png'70 },71 gif: {72 src: src + '/img/**/*.gif'73 },74 src: src + '/**/img/**/*',75 dest: dest + "",76 revJson: rev + "/rev-manifest-img.json"77 },78 //只处理json文件夹下面的json79 json: {80 src: src + '/**/json/**/*.json',81 dest: dest + "",82 revJson: rev + "/rev-manifest-json.json"83 },84 clean: {85 src: dest86 },87 html: {88 img: {89 src: src + '/html/**/img/**/*',90 dest: dest + "/html"91 },92 src: src + "/**/*.html",93 dest: dest + ""94 },95 //引用,构建图片时需要过滤掉libs下引用的图片96 libs: {97 img: {98 src: src + '/libs/**/img/**/*',99 dest: dest + "/libs"100 }101 },102 other: {103 project: {104 src: src + "/**/.project",105 },106 svn: {107 src: src + "/**/.svn/*",108 },109 settings: {110 src: src + "/**/.settings/*",111 },112 src: src + "/**/*",113 dest: dest + ""114 },115 rev: { //use rev to reset html resource url116 revJson: rev + "/**/*.json"117 },118 isMiniJs:isMiniJs119 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { revJson } = require('fast-check-monorepo');2const revJsonResult = revJson({ a: 1, b: 2 });3console.log(revJsonResult);4const { revJson } = require('fast-check-monorepo');5const revJsonResult = revJson({ a: 1, b: 2 });6console.log(revJsonResult);7const { revJson } = require('fast-check-monorepo');8const revJsonResult = revJson({ a: 1, b: 2 });9console.log(revJsonResult);10const { revJson } = require('fast-check-monorepo');11const revJsonResult = revJson({ a: 1, b: 2 });12console.log(revJsonResult);13const { revJson } = require('fast-check-monorepo');14const revJsonResult = revJson({ a: 1, b: 2 });15console.log(revJsonResult);16const { revJson } = require('fast-check-monorepo');17const revJsonResult = revJson({ a: 1, b: 2 });18console.log(revJsonResult);19const { revJson } = require('fast-check-monorepo');20const revJsonResult = revJson({ a: 1, b: 2 });21console.log(revJsonResult);22const { revJson } = require('fast-check-monorepo');23const revJsonResult = revJson({ a: 1, b: 2 });24console.log(revJsonResult);25const { revJson } = require('fast-check-monorepo');

Full Screen

Using AI Code Generation

copy

Full Screen

1const revJson = require('fast-check-monorepo').revJson;2const input = { a: 1, b: 2, c: 3 };3const output = revJson(input);4console.log(output);5const revJson = require('fast-check-monorepo').revJson;6const input = { a: 1, b: 2, c: 3 };7const output = revJson(input);8console.log(output);9const revJson = require('fast-check-monorepo').revJson;10const input = { a: 1, b: 2, c: 3 };11const output = revJson(input);12console.log(output);13const revJson = require('fast-check-monorepo').revJson;14const input = { a: 1, b: 2, c: 3 };15const output = revJson(input);16console.log(output);17const revJson = require('fast-check-monorepo').revJson;18const input = { a: 1, b: 2, c: 3 };19const output = revJson(input);20console.log(output);21const revJson = require('fast-check-monorepo').revJson;22const input = { a: 1, b: 2, c: 3 };23const output = revJson(input);24console.log(output);25const revJson = require('fast-check-monorepo').revJson;26const input = { a: 1, b: 2, c: 3 };27const output = revJson(input);28console.log(output);29const revJson = require('fast-check-monorepo').revJson;30const input = { a: 1, b: 2, c: 3 };

Full Screen

Using AI Code Generation

copy

Full Screen

1const revJson = require('fast-check-monorepo').revJson;2const obj = {a: 1, b: 2};3const rev = revJson(obj);4console.log(rev);5const revJson = require('fast-check-monorepo').revJson;6const obj = {a: 1, b: 2};7const rev = revJson(obj);8console.log(rev);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { revJson } = require('fast-check-monorepo');2const json = {3 d: { e: 1, f: 2 }4};5const rev = revJson(json);6console.log(rev);7const { revJson } = require('fast-check-monorepo');8const json = {9 d: { e: 1, f: 2 }10};11const rev = revJson(json);12console.log(rev);13const { revJson } = require('fast-check-monorepo');14const json = {15 d: { e: 1, f: 2 }16};17const rev = revJson(json);18console.log(rev);19const { revJson } = require('fast-check-monorepo');20const json = {21 d: { e: 1, f: 2 }22};23const rev = revJson(json);24console.log(rev);25const { revJson } = require('fast-check-monorepo');26const json = {27 d: { e: 1, f: 2 }28};29const rev = revJson(json);30console.log(rev);31const { revJson } = require('fast-check-monorepo');32const json = {33 d: { e:

Full Screen

Using AI Code Generation

copy

Full Screen

1const { revJson } = require('fast-check-monorepo');2const { fc } = require('fast-check');3const arb = fc.object();4const revJsonArb = arb.map(revJson);5fc.assert(6 fc.property(revJsonArb, (a) => {7 return JSON.parse(revJson(JSON.stringify(a))) === a;8 })9);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const revJson = require('fast-check').revJson;3const revJsonTests = () => {4 it('should return an empty string when given an empty string', () => {5 fc.assert(6 fc.property(fc.string(), (s) => {7 revJson(s).should.equal('');8 })9 );10 });11};12describe('revJson', revJsonTests);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { revJson } = require('fast-check-monorepo');2const { check, property } = require('fast-check');3const revJsonProp = property(4 check.anyJson(),5 (a) => revJson(revJson(a)) === a6);7check(revJsonProp);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful