GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — rm jscsrc, update Makefile, support node_modules/dist · gitbbrid/cube@2501155

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .jscsrc
  • .jshintrc
  • Makefile
  • bin
    • cube
  • example
    • .cubeignore
    • cube.json
    • cube.min.js
    • test
      • test_babel.jsx
      • test_css.coffee
      • test_cycle_require.coffee
      • test_less.coffee
      • test_main.js
      • test_require_with_var.coffee
      • test_styl.coffee
      • test_undefined_file.js
  • index.js
  • lib
    • processor_js2.js
  • package.json
  • runtime
    • cube.js
    • cube.min.js
    • cube_css.js
    • cube_css.min.js
  • test
    • index.js
    • runtime
      • cube.js
  • tools.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.jscsrc‎

Copy file name to clipboardExpand all lines: .jscsrc
-10Lines changed: 0 additions & 10 deletions
This file was deleted.
Collapse file

‎.jshintrc‎

Copy file name to clipboardExpand all lines: .jshintrc
-44Lines changed: 0 additions & 44 deletions
This file was deleted.
Collapse file

‎Makefile‎

Copy file name to clipboardExpand all lines: Makefile
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ release:
1010
@$(UG) ./runtime/jade_runtime.js -m -o ./runtime/jade_runtime.min.js
1111
@$(UG) ./runtime/cube_css.js -m -o ./runtime/cube_css.min.js
1212

13-
publish: release
13+
publish: release tag
1414
@npm publish
1515

16+
tag:
17+
@cat package.json | awk -F '"' '/version" *: *"/{print "v"$$4}' | xargs -I {} git tag {}
18+
1619
test:
1720
@npm run test
1821

1922
test-cov:
2023
@npm run testcov
2124

2225
.PHONY: \
23-
install release publish test test-cov
26+
install release publish test test-cov tag
Collapse file

‎bin/cube‎

Copy file name to clipboardExpand all lines: bin/cube
+129-45Lines changed: 129 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,8 @@ var cmd = require('commander');
44
var Cube = require('../index');
55
var fs = require('xfs');
66
var path = require('path');
7-
var JsProcessor = require('../lib/processor_js2');
87
var pkg = require(path.join(__dirname, '../package'));
9-
var spawn = require('child_process').spawn;
10-
11-
function exec(cmd, cb) {
12-
var args = cmd.split(/\s/);
13-
cmd = spawn(args[0], args.slice(1), process.env);
14-
cmd.stdout.on('data', function (data) {
15-
console.log(data.toString());
16-
});
17-
cmd.stdout.on('error', function (data) {
18-
console.log(data.toString());
19-
});
20-
21-
cmd.stderr.on('data', function (data) {
22-
console.log(data.toString());
23-
});
24-
cmd.stderr.on('error', function (data) {
25-
console.log(data.toString());
26-
});
27-
28-
cmd.on('close', cb);
29-
}
30-
8+
var childProcess = require('child_process');
319

3210
function getCwd() {
3311
return process.cwd();
@@ -130,42 +108,30 @@ cmd.command('install')
130108
.description('install dependences')
131109
.action(function (option, dir) {
132110
dir = dir ? filePath(dir) : getCwd();
133-
var cubeCfg;
134-
try {
135-
cubeCfg = require(path.join(dir, 'cube.json'));
136-
} catch (e) {
137-
console.log('nothing need to install');
138-
return;
111+
var out = childProcess.execSync('npm3 -v').toString().trim();
112+
var m = out.match(/(\d+)\.(\d+)\.(\d+)/);
113+
if (!m) {
114+
console.log('[Error] npm3 not installed');
115+
console.log('using this cmd: npm install -g npm3');
116+
process.exit(1);
139117
}
140-
var deps = cubeCfg.deps || cubeCfg.dependencies;
141-
if (!deps) {
142-
return;
143-
}
144-
var pkgList = [];
145-
Object.keys(deps).forEach(function (v) {
146-
pkgList.push(v + '@' + deps[v]);
147-
});
148-
exec('npm install ' + pkgList.join(' '), function (code) {
149-
console.log('install ended', code);
150-
});
118+
childProcess.execSync('npm3 install');
151119
});
152120

153121
cmd.command('update')
154122
.description('update cube.min.js')
155-
.option('--min', 'simple cube.min.js, no other run_time inculde')
123+
.option('-a, --all', 'simple cube.min.js, no other run_time inculde')
156124
.action(function (option) {
157125
findCube(function (cubeFile) {
158126
if (!cubeFile) {
159127
return;
160128
}
161129
var codeCube = '//cube.min.js\n' + fs.readFileSync(sourcePath('./runtime/cube.min.js')).toString();
162-
if (!option.min) {
130+
if (option.all) {
163131
console.log('enabled jade');
164132
codeCube += '\n//jade_runtime\n' + fs.readFileSync(sourcePath('./runtime/jade_runtime.min.js'));
165133
console.log('enabled ejs');
166134
codeCube += '\n//ejs_runtime\n' + fs.readFileSync(sourcePath('./runtime/ejs_runtime.min.js'));
167-
console.log('enabled mcss');
168-
codeCube += '\n//cube_css.min.js\n' + fs.readFileSync(sourcePath('./runtime/cube_css.min.js'));
169135
optmizeInfo();
170136
}
171137
fs.sync().save(cubeFile, codeCube);
@@ -259,10 +225,126 @@ cmd.command('build')
259225
}
260226
});
261227

228+
/**
229+
* build into single file
230+
*/
231+
cmd.command('all-in-one')
232+
.usage('-p processor1,processor2 your_file')
233+
.option('-o, --output [value]', 'output file')
234+
.option('-b, --base [value]', 'set dir base')
235+
.option('-r, --resbase [value]', 'resource base')
236+
.action(function (source, args) {
237+
if (!args || !source) {
238+
return this.help();
239+
}
240+
if (args.processors) {
241+
args.processors = args.processors.split(',');
242+
args.processors.forEach(function (v, i, a) {
243+
a[i] = v.trim();
244+
});
245+
}
246+
247+
var cwd = getCwd();
248+
var outputPath, cube, tool, root;
249+
var compress = true;
250+
var fstat;
251+
root = args.base ? args.base : '';
252+
if (root) {
253+
root = isAbsPath(root) ? root : path.join(cwd, root);
254+
}
255+
source = isAbsPath(source) ? source : path.join(cwd, source);
256+
try {
257+
fstat = fs.statSync(source);
258+
} catch (e) {
259+
console.log('source not fould', e);
260+
this.help();
261+
return;
262+
}
263+
if (fstat.isDirectory()) {
264+
console.log('proess file only');
265+
return ;
266+
}
267+
outputPath = args.output ? (isAbsPath(args.output) ? args.output : path.join(cwd, args.output)) : source.replace(/\.(\w+)$/, '.release');
268+
root = (root ? root : path.dirname(source)).replace(/(\/|\\)$/, '');
269+
cube = new Cube({
270+
release: true,
271+
root: root,
272+
compress: compress,
273+
middleware: false,
274+
processors: args.processors,
275+
resBase: args.resbase,
276+
remote: args.remote
277+
});
278+
tool = Cube.getTool();
279+
var codes = [];
280+
var styles = [];
281+
var infos = [];
282+
var codesMap = {};
283+
var indent = 0;
284+
function _cb(err, res, i) {
285+
if (err.length) {
286+
err.forEach(function () {
287+
288+
});
289+
return ;
290+
}
291+
var result = res.result;
292+
if (codesMap[result.file]) {
293+
return;
294+
}
295+
codesMap[result.file] = true;
296+
if (result.type === 'style') {
297+
styles.push(result.code);
298+
} else {
299+
codes.unshift(result.type !== 'script' ? result.wraped : result.code);
300+
}
301+
infos.push(fmtInfo(i, result.file));
302+
if (result.originalRequires) {
303+
var n = i + 1;
304+
result.originalRequires.forEach(function (m) {
305+
if (!fs.existsSync(path.join(root, m))) {
306+
return console.error('[error] missing require:', m);
307+
}
308+
if (codesMap[m]) {
309+
return;
310+
}
311+
312+
tool.processFile(cube, path.join(root, m), null, {}, function (err, data) {
313+
_cb(err, data, n);
314+
});
315+
});
316+
}
317+
}
318+
tool.processFile(cube, source, null, {}, function (err, data) {
319+
_cb(err, data, indent);
320+
});
321+
codes.unshift('var Cube = g.Cube;');
322+
codes.unshift(fs.readFileSync(path.join(__dirname, '../runtime/cube.min.js')).toString().replace('window,null', 'g,null'));
323+
codes.unshift('!(function(host, propName){\nvar g = {};');
324+
codes.push('Cube.use("' + infos[0] + '", function(mod) { host[propName] = mod;});');
325+
codes.push('})(host, "cubeExports")');
326+
fs.sync().save(path.join(outputPath, '/script.js'), codes.join('\n'));
327+
fs.sync().save(path.join(outputPath, '/style.css'), styles.join('\n'));
328+
console.log('===== deps =====');
329+
console.log(infos.join('\n'));
330+
console.log('======');
331+
console.log('output dir:', outputPath);
332+
console.log('======');
333+
});
334+
335+
function fmtInfo(indent) {
336+
var args = [].slice.call(arguments, 1);
337+
var str = [];
338+
for (var i = 0 ; i < indent ; i ++) {
339+
str.push(' ');
340+
}
341+
args.unshift(str.join(''));
342+
return args.join('');
343+
}
344+
262345
/**
263346
* build工程目录,并进行自动合并优化
264347
* node_modules目录将进行选择性build
265-
*
266348
*/
267349
cmd.command('smart-build')
268350
/**
@@ -340,6 +422,7 @@ cmd.command('smart-build')
340422
}
341423
});
342424

425+
/*
343426
cmd.command('dag')
344427
.usage('your_code_dir')
345428
.description('gen DAG graph')
@@ -397,6 +480,7 @@ cmd.command('dag')
397480
console.log('browser open: ' + root + '/dag_out.html');
398481
}
399482
});
483+
*/
400484

401485
cmd.command('help')
402486
.description('help')
Collapse file

‎example/.cubeignore‎

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[skip]
22
/lib/
3-
3+
/cube.min.js
44
[ignore]
55
/test/test_ignore.js
66
/node_modules/ignore/
Collapse file

‎example/cube.json‎

Copy file name to clipboardExpand all lines: example/cube.json
-21Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.