@voxgig/model 7.0.0 → 7.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/voxgig-model CHANGED
@@ -8,10 +8,12 @@ const Pkg = require('../package.json')
8
8
  const { Model } = require('../dist/model.js')
9
9
 
10
10
  const { Jsonic } = require('jsonic')
11
- const { Gubu, Fault, One } = require('gubu')
11
+ const { Gubu, Fault, One, Any } = require('gubu')
12
12
 
13
13
 
14
- let KONSOLE = console
14
+
15
+ let KONSOLE = global['con'+'sole']
16
+
15
17
 
16
18
  run()
17
19
 
@@ -109,7 +111,7 @@ function validateOptions(rawOptions) {
109
111
  watch: Boolean,
110
112
  debug: One(String,Boolean),
111
113
  dryrun: false,
112
- buildargs: '',
114
+ build: Any(),
113
115
  help: Boolean,
114
116
  version: Boolean,
115
117
  })
@@ -148,12 +150,6 @@ function version() {
148
150
  }
149
151
 
150
152
 
151
- function help() {
152
- const s = 'TODO'
153
- KONSOLE.log(s)
154
- }
155
-
156
-
157
153
  function exit(err) {
158
154
  let code = 0
159
155
  if(err) {
@@ -207,3 +203,43 @@ async function generate(options) {
207
203
  }
208
204
  }
209
205
 
206
+
207
+ function help() {
208
+ const s = `
209
+ Build a Voxgig model and generate dependent artifacts.
210
+
211
+ Usage: voxgig-model <root-file> <args>
212
+
213
+ <root-file> is the root file of the model.
214
+
215
+ <args> are the command arguments:
216
+
217
+ --dryrun Perform a dry run, where no files are modified.
218
+ -y
219
+
220
+ --build <spec> Provide a jsonic specification for build actions.
221
+ -b
222
+
223
+ --debug Set log level (default: info): trace, error, debug, info, warn, fatal.
224
+ -g
225
+
226
+ --help Print this help message.
227
+ -h
228
+
229
+ --version Print version number.
230
+ -v
231
+
232
+
233
+ Examples:
234
+
235
+ # Basic usage
236
+ > voxgig-model model/model.jsonic
237
+ # Builds a model defined in the file model/model.jsonic
238
+
239
+ See also: https://voxgig.com/model
240
+ `
241
+ KONSOLE.log(s)
242
+ }
243
+
244
+
245
+
@@ -1,5 +1,8 @@
1
1
 
2
2
 
3
- sys: model: builders: &: {
3
+ sys: model: action: &: {
4
4
  load: string
5
5
  }
6
+
7
+ sys: model: order: action: string
8
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/model",
3
- "version": "7.0.0",
3
+ "version": "7.2.0",
4
4
  "main": "dist/model.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/model.d.ts",
@@ -46,7 +46,7 @@
46
46
  "aontu": "0.28.0",
47
47
  "chokidar": "4.0.3",
48
48
  "gubu": "^9.0.0",
49
- "memfs": "^4.23.0"
49
+ "memfs": "^4.25.0"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@voxgig/util": ">=0",
@@ -1,3 +0,0 @@
1
- import type { Producer } from '../types';
2
- declare const local_builder: Producer;
3
- export { local_builder };
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.local_builder = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- // Runs any builders local to the repo.
9
- const local_builder = async (build, ctx) => {
10
- ctx.state.local = (ctx.state.local || {});
11
- let actionDefs = ctx.state.local.actionDefs;
12
- if (null == actionDefs) {
13
- actionDefs = ctx.state.local.actionDefs = [];
14
- // TODO: need to provide project root via build
15
- let root = path_1.default.resolve(build.path, '..', '..');
16
- // TODO: build should do this
17
- let configBuildResult = build.use.config.watch.last;
18
- let configBuild = configBuildResult?.build();
19
- let config = configBuild?.model || {};
20
- let builders = config.sys?.model.builders || {};
21
- // console.log('LOCAL BUILDERS', builders)
22
- // TODO: order by comma sep string
23
- // Load builders
24
- for (let name in builders) {
25
- let builder = builders[name];
26
- let action_path = path_1.default.join(root, builder.load);
27
- let action = require(action_path);
28
- if (action instanceof Promise) {
29
- action = await action;
30
- }
31
- const step = action.step || 'post';
32
- actionDefs.push({ name, builder, action, step });
33
- }
34
- // console.log('LOCAL ACTION DEFS', actionDefs)
35
- }
36
- const runActionDefs = actionDefs.filter((ad) => ctx.step === ad.step || 'all' === ad.step);
37
- build.log.info({
38
- point: ctx.step + '-actions', step: ctx.step, actions: runActionDefs,
39
- note: runActionDefs.map((ad) => ad.name).join(';')
40
- });
41
- let ok = true;
42
- let areslog = [];
43
- for (let actionDef of runActionDefs) {
44
- try {
45
- let ares = await actionDef.action(build.model, build, ctx);
46
- ok = ok && (null == ares || !!ares.ok);
47
- areslog.push(ares);
48
- if (!ok) {
49
- break;
50
- }
51
- }
52
- catch (err) {
53
- if (!err.__logged__) {
54
- build.log.error({
55
- point: ctx.step + '-action', step: ctx.step, action: actionDef,
56
- note: actionDef.name,
57
- err
58
- });
59
- err.__logged__ = true;
60
- }
61
- throw err;
62
- }
63
- }
64
- return { ok, step: ctx.step, active: true, errs: [], runlog: [] };
65
- };
66
- exports.local_builder = local_builder;
67
- //# sourceMappingURL=local.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/builder/local.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;AAKvB,uCAAuC;AACvC,MAAM,aAAa,GAAa,KAAK,EAAE,KAAY,EAAE,GAAiB,EAAE,EAAE;IACxE,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IACzC,IAAI,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAA;IAE3C,IAAI,IAAI,IAAI,UAAU,EAAE,CAAC;QACvB,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,EAAE,CAAA;QAE5C,+CAA+C;QAC/C,IAAI,IAAI,GAAG,cAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAE/C,6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@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.model_builder = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- // Builds the main model file, after unification.
9
- const model_builder = async (build, ctx) => {
10
- if ('post' !== ctx.step) {
11
- return { ok: true, step: ctx.step, active: false, errs: [], runlog: [] };
12
- }
13
- let json = JSON.stringify(build.model, null, 2);
14
- let filename = path_1.default.basename(build.path);
15
- let filenameparts = filename.match(/^(.*)\.[^.]+$/);
16
- if (filenameparts) {
17
- filename = filenameparts[1];
18
- }
19
- let file = build.opts.base + '/' + filename + '.json';
20
- build.log.info({
21
- point: 'write-model',
22
- path: file,
23
- note: file.replace(process.cwd(), '.')
24
- });
25
- build.fs.mkdirSync(path_1.default.dirname(file), { recursive: true });
26
- build.fs.writeFileSync(file, json);
27
- return { ok: true, step: ctx.step, active: true, errs: [], runlog: [] };
28
- };
29
- exports.model_builder = model_builder;
30
- //# sourceMappingURL=model.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/builder/model.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;AAKvB,iDAAiD;AACjD,MAAM,aAAa,GAAa,KAAK,EAAE,KAAY,EAAE,GAAiB,EAAE,EAAE;IACxE,IAAI,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;QACxB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;IAC1E,CAAC;IAED,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IAE/C,IAAI,QAAQ,GAAG,cAAI,CAAC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