@giteeteam/apps-cli 0.3.2 → 0.4.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/dist/index.js +740 -6
- package/package.json +10 -5
package/dist/index.js
CHANGED
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
|
|
4
4
|
require('dotenv/config');
|
|
5
5
|
var commander = require('commander');
|
|
6
|
-
var appsBundler = require('@giteeteam/apps-bundler');
|
|
7
6
|
var fse = require('fs-extra');
|
|
8
7
|
var path = require('path');
|
|
9
8
|
var archiver = require('archiver');
|
|
9
|
+
var rollup = require('rollup');
|
|
10
|
+
var fs = require('fs');
|
|
11
|
+
var esbuild$1 = require('esbuild');
|
|
12
|
+
var pluginNodeResolve = require('@rollup/plugin-node-resolve');
|
|
13
|
+
var commonjs = require('@rollup/plugin-commonjs');
|
|
10
14
|
var ora = require('ora');
|
|
11
15
|
var yaml = require('yaml');
|
|
16
|
+
var Ajv = require('ajv');
|
|
17
|
+
var AjvKeywords = require('ajv-keywords');
|
|
18
|
+
var lodash = require('lodash');
|
|
12
19
|
var inquirer = require('inquirer');
|
|
13
20
|
var simpleGit = require('simple-git');
|
|
14
21
|
var chalk = require('chalk');
|
|
@@ -22,7 +29,11 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
22
29
|
var fse__default = /*#__PURE__*/_interopDefaultLegacy(fse);
|
|
23
30
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
24
31
|
var archiver__default = /*#__PURE__*/_interopDefaultLegacy(archiver);
|
|
32
|
+
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
33
|
+
var commonjs__default = /*#__PURE__*/_interopDefaultLegacy(commonjs);
|
|
25
34
|
var ora__default = /*#__PURE__*/_interopDefaultLegacy(ora);
|
|
35
|
+
var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
|
|
36
|
+
var AjvKeywords__default = /*#__PURE__*/_interopDefaultLegacy(AjvKeywords);
|
|
26
37
|
var inquirer__default = /*#__PURE__*/_interopDefaultLegacy(inquirer);
|
|
27
38
|
var simpleGit__default = /*#__PURE__*/_interopDefaultLegacy(simpleGit);
|
|
28
39
|
var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
|
|
@@ -30,7 +41,7 @@ var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
|
30
41
|
var child_process__default = /*#__PURE__*/_interopDefaultLegacy(child_process);
|
|
31
42
|
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar);
|
|
32
43
|
|
|
33
|
-
var version = "0.
|
|
44
|
+
var version = "0.4.0";
|
|
34
45
|
|
|
35
46
|
const packageApp = async ({ outputDir, manifest, copyFiles }) => {
|
|
36
47
|
const { resources } = manifest;
|
|
@@ -89,11 +100,98 @@ const archiveApp = async (archiveDir, pkgName) => {
|
|
|
89
100
|
});
|
|
90
101
|
};
|
|
91
102
|
|
|
103
|
+
const defaultOptions = {
|
|
104
|
+
treeShaking: true,
|
|
105
|
+
format: 'esm',
|
|
106
|
+
loader: 'tsx',
|
|
107
|
+
};
|
|
108
|
+
function esbuild(options) {
|
|
109
|
+
options = { ...defaultOptions, ...options };
|
|
110
|
+
return {
|
|
111
|
+
name: 'esbuild',
|
|
112
|
+
resolveId(source, importer, opts) {
|
|
113
|
+
// console.log('resolveId:');
|
|
114
|
+
// console.dir({ source, importer, opts }, { depth: null });
|
|
115
|
+
if (!importer || ['.ts', '.tsx', '.js', '.jsx'].some(ext => source.endsWith(ext))) {
|
|
116
|
+
return source;
|
|
117
|
+
}
|
|
118
|
+
const dirPath = path.dirname(importer);
|
|
119
|
+
let path$1;
|
|
120
|
+
if (fs.existsSync((path$1 = path.resolve(dirPath, source, 'index.ts')))) {
|
|
121
|
+
return path$1;
|
|
122
|
+
}
|
|
123
|
+
else if (fs.existsSync((path$1 = path.resolve(dirPath, source, 'index.tsx')))) {
|
|
124
|
+
return path$1;
|
|
125
|
+
}
|
|
126
|
+
else if (fs.existsSync((path$1 = path.resolve(dirPath, source + '.ts')))) {
|
|
127
|
+
return path$1;
|
|
128
|
+
}
|
|
129
|
+
else if (fs.existsSync((path$1 = path.resolve(dirPath, source + '.tsx')))) {
|
|
130
|
+
return path$1;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
console.error({ source, importer, options: opts });
|
|
134
|
+
path$1 = path.relative('.', path.resolve(importer, source));
|
|
135
|
+
throw new Error(`ENOENT: ${path$1.replace(/\\/g, '/')}`);
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
async transform(src, id) {
|
|
139
|
+
options.sourcefile = id;
|
|
140
|
+
const { code, map } = await esbuild$1.transform(src, options);
|
|
141
|
+
if (!map)
|
|
142
|
+
return code;
|
|
143
|
+
return { code, map };
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var MODE;
|
|
149
|
+
(function (MODE) {
|
|
150
|
+
MODE["DEV"] = "development";
|
|
151
|
+
MODE["PROD"] = "production";
|
|
152
|
+
})(MODE || (MODE = {}));
|
|
153
|
+
function getRollupOptions(input, outputFile, mode = MODE.DEV) {
|
|
154
|
+
const plugins = [pluginNodeResolve.nodeResolve(), commonjs__default["default"]()];
|
|
155
|
+
plugins.push(esbuild({
|
|
156
|
+
sourcemap: mode === MODE.DEV,
|
|
157
|
+
minify: mode !== MODE.DEV,
|
|
158
|
+
target: 'es2018',
|
|
159
|
+
jsx: 'transform',
|
|
160
|
+
jsxFactory: 'AppsUI.createElement',
|
|
161
|
+
jsxFragment: 'AppsUI.Fragment',
|
|
162
|
+
}));
|
|
163
|
+
const inputOptions = {
|
|
164
|
+
input,
|
|
165
|
+
plugins,
|
|
166
|
+
};
|
|
167
|
+
const outputOptions = {
|
|
168
|
+
file: outputFile,
|
|
169
|
+
format: 'es',
|
|
170
|
+
sourcemap: mode === MODE.DEV,
|
|
171
|
+
};
|
|
172
|
+
return { inputOptions, outputOptions };
|
|
173
|
+
}
|
|
174
|
+
async function bundle(opts) {
|
|
175
|
+
const { fileName, inputDir, outputDir, mode = MODE.DEV } = opts;
|
|
176
|
+
const input = path__default["default"].join(inputDir, `${fileName}.ts`);
|
|
177
|
+
try {
|
|
178
|
+
await fs__default["default"].promises.access(input);
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
console.error(`${input} is not exist`);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const outputFile = path__default["default"].join(outputDir, `${fileName}.js`);
|
|
185
|
+
const { inputOptions, outputOptions } = getRollupOptions(input, outputFile, mode);
|
|
186
|
+
const build = await rollup.rollup(inputOptions);
|
|
187
|
+
await build.write(outputOptions);
|
|
188
|
+
}
|
|
189
|
+
|
|
92
190
|
const bundleApp = async (opts) => {
|
|
93
191
|
const { manifest, mode, outputDir, inputDir } = opts;
|
|
94
192
|
const functionFiles = manifest.getFunctionFiles();
|
|
95
193
|
const bundlePromise = functionFiles.map(async (fileName) => {
|
|
96
|
-
await
|
|
194
|
+
await bundle({
|
|
97
195
|
inputDir,
|
|
98
196
|
fileName,
|
|
99
197
|
outputDir,
|
|
@@ -116,6 +214,635 @@ const execActionWithSpinner = async (message, action) => {
|
|
|
116
214
|
spinner.succeed(message.succeed);
|
|
117
215
|
};
|
|
118
216
|
|
|
217
|
+
var $id$b = "http://proxima.com/schemas/all.json";
|
|
218
|
+
var type$b = "object";
|
|
219
|
+
var properties$7 = {
|
|
220
|
+
app: {
|
|
221
|
+
$ref: "app.json"
|
|
222
|
+
},
|
|
223
|
+
modules: {
|
|
224
|
+
$ref: "modules/index.json"
|
|
225
|
+
},
|
|
226
|
+
resources: {
|
|
227
|
+
$ref: "resources.json"
|
|
228
|
+
},
|
|
229
|
+
tables: {
|
|
230
|
+
$ref: "tables.json"
|
|
231
|
+
},
|
|
232
|
+
locales: {
|
|
233
|
+
$ref: "locales.json"
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
var required$7 = [
|
|
237
|
+
"app"
|
|
238
|
+
];
|
|
239
|
+
var additionalProperties$4 = false;
|
|
240
|
+
var allSchema = {
|
|
241
|
+
$id: $id$b,
|
|
242
|
+
type: type$b,
|
|
243
|
+
properties: properties$7,
|
|
244
|
+
required: required$7,
|
|
245
|
+
additionalProperties: additionalProperties$4
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
var $id$a = "http://proxima.com/schemas/app.json";
|
|
249
|
+
var type$a = "object";
|
|
250
|
+
var required$6 = [
|
|
251
|
+
"name",
|
|
252
|
+
"key",
|
|
253
|
+
"version"
|
|
254
|
+
];
|
|
255
|
+
var properties$6 = {
|
|
256
|
+
key: {
|
|
257
|
+
type: "string",
|
|
258
|
+
regexp: "/^[a-z][a-z0-9_]*$/gi"
|
|
259
|
+
},
|
|
260
|
+
name: {
|
|
261
|
+
type: "string"
|
|
262
|
+
},
|
|
263
|
+
version: {
|
|
264
|
+
type: "string"
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
var appSchema = {
|
|
268
|
+
$id: $id$a,
|
|
269
|
+
type: type$a,
|
|
270
|
+
required: required$6,
|
|
271
|
+
properties: properties$6
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
var $id$9 = "http://proxima.com/schemas/modules/index.json";
|
|
275
|
+
var type$9 = "object";
|
|
276
|
+
var patternProperties$1 = {
|
|
277
|
+
"^(adminPage|itemPanel|itemActivity|appPage|viewAction)$": {
|
|
278
|
+
type: "array",
|
|
279
|
+
uniqueItems: true,
|
|
280
|
+
uniqueItemProperties: [
|
|
281
|
+
"key"
|
|
282
|
+
],
|
|
283
|
+
minItems: 1,
|
|
284
|
+
additionalItems: true,
|
|
285
|
+
items: [
|
|
286
|
+
{
|
|
287
|
+
$ref: "frontend/base.json"
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
"^(webtrigger)$": {
|
|
292
|
+
type: "array",
|
|
293
|
+
uniqueItems: true,
|
|
294
|
+
uniqueItemProperties: [
|
|
295
|
+
"key"
|
|
296
|
+
],
|
|
297
|
+
minItems: 1,
|
|
298
|
+
additionalItems: true,
|
|
299
|
+
items: [
|
|
300
|
+
{
|
|
301
|
+
$ref: "trigger/webtrigger.json"
|
|
302
|
+
}
|
|
303
|
+
]
|
|
304
|
+
},
|
|
305
|
+
"^(trigger)$": {
|
|
306
|
+
type: "array",
|
|
307
|
+
uniqueItems: true,
|
|
308
|
+
uniqueItemProperties: [
|
|
309
|
+
"key"
|
|
310
|
+
],
|
|
311
|
+
minItems: 1,
|
|
312
|
+
additionalItems: true,
|
|
313
|
+
items: [
|
|
314
|
+
{
|
|
315
|
+
$ref: "trigger/base.json"
|
|
316
|
+
}
|
|
317
|
+
]
|
|
318
|
+
},
|
|
319
|
+
"^(function)$": {
|
|
320
|
+
type: "array",
|
|
321
|
+
uniqueItems: true,
|
|
322
|
+
uniqueItemProperties: [
|
|
323
|
+
"key"
|
|
324
|
+
],
|
|
325
|
+
minItems: 1,
|
|
326
|
+
additionalItems: true,
|
|
327
|
+
items: [
|
|
328
|
+
{
|
|
329
|
+
$ref: "function/base.json"
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
},
|
|
333
|
+
"^(customFieldType)$": {
|
|
334
|
+
type: "array",
|
|
335
|
+
uniqueItems: true,
|
|
336
|
+
uniqueItemProperties: [
|
|
337
|
+
"key"
|
|
338
|
+
],
|
|
339
|
+
minItems: 1,
|
|
340
|
+
additionalItems: true,
|
|
341
|
+
items: [
|
|
342
|
+
{
|
|
343
|
+
$ref: "custom-field/type.json"
|
|
344
|
+
}
|
|
345
|
+
]
|
|
346
|
+
},
|
|
347
|
+
"^(customField)$": {
|
|
348
|
+
type: "array",
|
|
349
|
+
uniqueItems: true,
|
|
350
|
+
uniqueItemProperties: [
|
|
351
|
+
"key"
|
|
352
|
+
],
|
|
353
|
+
minItems: 1,
|
|
354
|
+
additionalItems: true,
|
|
355
|
+
items: [
|
|
356
|
+
{
|
|
357
|
+
$ref: "custom-field/field.json"
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
var additionalProperties$3 = true;
|
|
363
|
+
var minProperties$1 = 1;
|
|
364
|
+
var modulesSchema = {
|
|
365
|
+
$id: $id$9,
|
|
366
|
+
type: type$9,
|
|
367
|
+
patternProperties: patternProperties$1,
|
|
368
|
+
additionalProperties: additionalProperties$3,
|
|
369
|
+
minProperties: minProperties$1
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
var type$8 = "object";
|
|
373
|
+
var $id$8 = "http://proxima.com/schemas/modules/frontend/base.json";
|
|
374
|
+
var additionalProperties$2 = true;
|
|
375
|
+
var properties$5 = {
|
|
376
|
+
key: {
|
|
377
|
+
type: "string"
|
|
378
|
+
},
|
|
379
|
+
resource: {
|
|
380
|
+
type: "string"
|
|
381
|
+
},
|
|
382
|
+
title: {
|
|
383
|
+
type: "string"
|
|
384
|
+
},
|
|
385
|
+
loadType: {
|
|
386
|
+
type: "string"
|
|
387
|
+
},
|
|
388
|
+
route: {
|
|
389
|
+
type: "string"
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
var required$5 = [
|
|
393
|
+
"key",
|
|
394
|
+
"resource",
|
|
395
|
+
"title"
|
|
396
|
+
];
|
|
397
|
+
var frontendBaseSchema = {
|
|
398
|
+
type: type$8,
|
|
399
|
+
$id: $id$8,
|
|
400
|
+
additionalProperties: additionalProperties$2,
|
|
401
|
+
properties: properties$5,
|
|
402
|
+
required: required$5
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
var type$7 = "object";
|
|
406
|
+
var $id$7 = "http://proxima.com/schemas/modules/trigger/base.json";
|
|
407
|
+
var properties$4 = {
|
|
408
|
+
key: {
|
|
409
|
+
type: "string"
|
|
410
|
+
},
|
|
411
|
+
events: {
|
|
412
|
+
type: "array",
|
|
413
|
+
uniqueItems: true,
|
|
414
|
+
minItems: 1,
|
|
415
|
+
additionalItems: true,
|
|
416
|
+
items: [
|
|
417
|
+
{
|
|
418
|
+
type: "string"
|
|
419
|
+
}
|
|
420
|
+
]
|
|
421
|
+
},
|
|
422
|
+
"function": {
|
|
423
|
+
type: "string"
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
var required$4 = [
|
|
427
|
+
"key",
|
|
428
|
+
"events",
|
|
429
|
+
"function"
|
|
430
|
+
];
|
|
431
|
+
var triggerSchema = {
|
|
432
|
+
type: type$7,
|
|
433
|
+
$id: $id$7,
|
|
434
|
+
properties: properties$4,
|
|
435
|
+
required: required$4
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
var type$6 = "object";
|
|
439
|
+
var $id$6 = "http://proxima.com/schemas/modules/trigger/webtrigger.json";
|
|
440
|
+
var properties$3 = {
|
|
441
|
+
key: {
|
|
442
|
+
type: "string"
|
|
443
|
+
},
|
|
444
|
+
"function": {
|
|
445
|
+
type: "string"
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
var required$3 = [
|
|
449
|
+
"key",
|
|
450
|
+
"function"
|
|
451
|
+
];
|
|
452
|
+
var webtriggerSchema = {
|
|
453
|
+
type: type$6,
|
|
454
|
+
$id: $id$6,
|
|
455
|
+
properties: properties$3,
|
|
456
|
+
required: required$3
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
var type$5 = "object";
|
|
460
|
+
var $id$5 = "http://proxima.com/schemas/modules/function/base.json";
|
|
461
|
+
var properties$2 = {
|
|
462
|
+
key: {
|
|
463
|
+
type: "string"
|
|
464
|
+
},
|
|
465
|
+
handler: {
|
|
466
|
+
type: "string"
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
var required$2 = [
|
|
470
|
+
"key",
|
|
471
|
+
"handler"
|
|
472
|
+
];
|
|
473
|
+
var functionSchema = {
|
|
474
|
+
type: type$5,
|
|
475
|
+
$id: $id$5,
|
|
476
|
+
properties: properties$2,
|
|
477
|
+
required: required$2
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
var type$4 = "object";
|
|
481
|
+
var $id$4 = "http://proxima.com/schemas/modules/custom-field/field.json";
|
|
482
|
+
var additionalProperties$1 = true;
|
|
483
|
+
var properties$1 = {
|
|
484
|
+
key: {
|
|
485
|
+
type: "string"
|
|
486
|
+
},
|
|
487
|
+
name: {
|
|
488
|
+
type: "string"
|
|
489
|
+
},
|
|
490
|
+
type: {
|
|
491
|
+
type: "string"
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
var required$1 = [
|
|
495
|
+
"key",
|
|
496
|
+
"name",
|
|
497
|
+
"type"
|
|
498
|
+
];
|
|
499
|
+
var customFieldSchema = {
|
|
500
|
+
type: type$4,
|
|
501
|
+
$id: $id$4,
|
|
502
|
+
additionalProperties: additionalProperties$1,
|
|
503
|
+
properties: properties$1,
|
|
504
|
+
required: required$1
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
var type$3 = "object";
|
|
508
|
+
var $id$3 = "http://proxima.com/schemas/modules/custom-field/type.json";
|
|
509
|
+
var properties = {
|
|
510
|
+
key: {
|
|
511
|
+
type: "string"
|
|
512
|
+
},
|
|
513
|
+
name: {
|
|
514
|
+
type: "string"
|
|
515
|
+
},
|
|
516
|
+
resource: {
|
|
517
|
+
type: "string"
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
var required = [
|
|
521
|
+
"key",
|
|
522
|
+
"name"
|
|
523
|
+
];
|
|
524
|
+
var customFieldTypeSchema = {
|
|
525
|
+
type: type$3,
|
|
526
|
+
$id: $id$3,
|
|
527
|
+
properties: properties,
|
|
528
|
+
required: required
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
var $id$2 = "http://proxima.com/schemas/resources.json";
|
|
532
|
+
var type$2 = "array";
|
|
533
|
+
var minItems$1 = 1;
|
|
534
|
+
var uniqueItems$1 = true;
|
|
535
|
+
var uniqueItemProperties$1 = [
|
|
536
|
+
"key"
|
|
537
|
+
];
|
|
538
|
+
var items$1 = {
|
|
539
|
+
type: "object",
|
|
540
|
+
properties: {
|
|
541
|
+
key: {
|
|
542
|
+
type: "string"
|
|
543
|
+
},
|
|
544
|
+
path: {
|
|
545
|
+
type: "string"
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
required: [
|
|
549
|
+
"key",
|
|
550
|
+
"path"
|
|
551
|
+
]
|
|
552
|
+
};
|
|
553
|
+
var resourcesSchema = {
|
|
554
|
+
$id: $id$2,
|
|
555
|
+
type: type$2,
|
|
556
|
+
minItems: minItems$1,
|
|
557
|
+
uniqueItems: uniqueItems$1,
|
|
558
|
+
uniqueItemProperties: uniqueItemProperties$1,
|
|
559
|
+
items: items$1
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
var $id$1 = "http://proxima.com/schemas/tables.json";
|
|
563
|
+
var type$1 = "array";
|
|
564
|
+
var minItems = 1;
|
|
565
|
+
var uniqueItems = true;
|
|
566
|
+
var uniqueItemProperties = [
|
|
567
|
+
"className"
|
|
568
|
+
];
|
|
569
|
+
var items = {
|
|
570
|
+
type: "object",
|
|
571
|
+
properties: {
|
|
572
|
+
className: {
|
|
573
|
+
type: "string",
|
|
574
|
+
regexp: {
|
|
575
|
+
pattern: "(^_([a-zA-Z0-9]_?)*$)|(^[a-zA-Z](_?[a-zA-Z0-9])*_?$)",
|
|
576
|
+
flags: "i"
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
fields: {
|
|
580
|
+
type: "object",
|
|
581
|
+
patternProperties: {
|
|
582
|
+
"(^_([a-zA-Z0-9]_?)*$)|(^[a-zA-Z](_?[a-zA-Z0-9])*_?$)": {
|
|
583
|
+
type: "object",
|
|
584
|
+
anyOf: [
|
|
585
|
+
{
|
|
586
|
+
type: "object",
|
|
587
|
+
properties: {
|
|
588
|
+
type: {
|
|
589
|
+
type: "string",
|
|
590
|
+
"enum": [
|
|
591
|
+
"Pointer",
|
|
592
|
+
"Relation"
|
|
593
|
+
]
|
|
594
|
+
},
|
|
595
|
+
targetClass: {
|
|
596
|
+
type: "string",
|
|
597
|
+
regexp: {
|
|
598
|
+
pattern: "(^_([a-zA-Z0-9]_?)*$)|(^[a-zA-Z](_?[a-zA-Z0-9])*_?$)",
|
|
599
|
+
flags: "i"
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
isAppClass: {
|
|
603
|
+
type: "boolean",
|
|
604
|
+
"default": false
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
required: [
|
|
608
|
+
"type",
|
|
609
|
+
"targetClass"
|
|
610
|
+
]
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
type: "object",
|
|
614
|
+
properties: {
|
|
615
|
+
type: {
|
|
616
|
+
type: "string",
|
|
617
|
+
"const": "String"
|
|
618
|
+
},
|
|
619
|
+
defaultValue: {
|
|
620
|
+
type: "string"
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
required: [
|
|
624
|
+
"type"
|
|
625
|
+
]
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
type: "object",
|
|
629
|
+
properties: {
|
|
630
|
+
type: {
|
|
631
|
+
type: "string",
|
|
632
|
+
"const": "Boolean"
|
|
633
|
+
},
|
|
634
|
+
defaultValue: {
|
|
635
|
+
type: "boolean"
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
required: [
|
|
639
|
+
"type"
|
|
640
|
+
]
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
type: "object",
|
|
644
|
+
properties: {
|
|
645
|
+
type: {
|
|
646
|
+
type: "string",
|
|
647
|
+
"const": "Number"
|
|
648
|
+
},
|
|
649
|
+
defaultValue: {
|
|
650
|
+
type: "number"
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
required: [
|
|
654
|
+
"type"
|
|
655
|
+
]
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
type: "object",
|
|
659
|
+
properties: {
|
|
660
|
+
type: {
|
|
661
|
+
type: "string",
|
|
662
|
+
"const": "Object"
|
|
663
|
+
},
|
|
664
|
+
defaultValue: {
|
|
665
|
+
type: "object"
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
required: [
|
|
669
|
+
"type"
|
|
670
|
+
]
|
|
671
|
+
},
|
|
672
|
+
{
|
|
673
|
+
type: "object",
|
|
674
|
+
properties: {
|
|
675
|
+
type: {
|
|
676
|
+
type: "string",
|
|
677
|
+
"const": "Array"
|
|
678
|
+
},
|
|
679
|
+
defaultValue: {
|
|
680
|
+
type: "array"
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
required: [
|
|
684
|
+
"type"
|
|
685
|
+
]
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
type: "object",
|
|
689
|
+
properties: {
|
|
690
|
+
type: {
|
|
691
|
+
type: "string",
|
|
692
|
+
"enum": [
|
|
693
|
+
"Date",
|
|
694
|
+
"File"
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
required: [
|
|
699
|
+
"type"
|
|
700
|
+
]
|
|
701
|
+
}
|
|
702
|
+
]
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
additionalProperties: false
|
|
706
|
+
}
|
|
707
|
+
},
|
|
708
|
+
required: [
|
|
709
|
+
"className",
|
|
710
|
+
"fields"
|
|
711
|
+
]
|
|
712
|
+
};
|
|
713
|
+
var tablesSchema = {
|
|
714
|
+
$id: $id$1,
|
|
715
|
+
type: type$1,
|
|
716
|
+
minItems: minItems,
|
|
717
|
+
uniqueItems: uniqueItems,
|
|
718
|
+
uniqueItemProperties: uniqueItemProperties,
|
|
719
|
+
items: items
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
var $id = "http://proxima.com/schemas/locales.json";
|
|
723
|
+
var type = "object";
|
|
724
|
+
var patternProperties = {
|
|
725
|
+
"^(en-US|zh-CN)$": {
|
|
726
|
+
type: "object",
|
|
727
|
+
additionalProperties: true
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
var additionalProperties = true;
|
|
731
|
+
var minProperties = 1;
|
|
732
|
+
var localesSchema = {
|
|
733
|
+
$id: $id,
|
|
734
|
+
type: type,
|
|
735
|
+
patternProperties: patternProperties,
|
|
736
|
+
additionalProperties: additionalProperties,
|
|
737
|
+
minProperties: minProperties
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
const validateResource = (json) => {
|
|
741
|
+
const errors = [];
|
|
742
|
+
const frontendModules = ['adminPage', 'itemPanel', 'itemActivity', 'appPage'];
|
|
743
|
+
const modules = lodash.get(json, 'modules') || {};
|
|
744
|
+
const resourcesEntries = lodash.keyBy(lodash.get(json, 'resources'), 'key');
|
|
745
|
+
const functionEntries = lodash.keyBy(lodash.get(json, 'modules.function'), 'key');
|
|
746
|
+
const customFieldTypeEntries = lodash.keyBy(lodash.get(json, 'modules.customFieldType'), 'key');
|
|
747
|
+
const moduleKeys = {};
|
|
748
|
+
Object.keys(modules).forEach(moduleKey => {
|
|
749
|
+
const module = lodash.get(modules, moduleKey);
|
|
750
|
+
if (!module)
|
|
751
|
+
return;
|
|
752
|
+
const isFrontendModule = frontendModules.indexOf(moduleKey) > -1;
|
|
753
|
+
Array.from(module).forEach(({ resource, function: functionRef, type, key }, index) => {
|
|
754
|
+
const path = `/modules/${moduleKey}/${index}`;
|
|
755
|
+
if (moduleKeys[key]) {
|
|
756
|
+
errors.push({
|
|
757
|
+
path,
|
|
758
|
+
message: `Key '${key}' has already exits! `,
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
else {
|
|
762
|
+
moduleKeys[key] = true;
|
|
763
|
+
}
|
|
764
|
+
if (isFrontendModule) {
|
|
765
|
+
if (resource && !lodash.get(resourcesEntries, resource)) {
|
|
766
|
+
errors.push({
|
|
767
|
+
path,
|
|
768
|
+
message: `Resource '${resource}' not found! `,
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
else if (moduleKey === 'trigger' || moduleKey === 'webtrigger') {
|
|
773
|
+
if (functionRef && !lodash.get(functionEntries, functionRef)) {
|
|
774
|
+
errors.push({
|
|
775
|
+
path,
|
|
776
|
+
message: `Function '${functionRef}' not found! `,
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
else if (moduleKey === 'customField' && lodash.startsWith(type, '_self:')) {
|
|
781
|
+
const fieldTypeRef = type === null || type === void 0 ? void 0 : type.slice(6);
|
|
782
|
+
if (fieldTypeRef && !lodash.get(customFieldTypeEntries, fieldTypeRef)) {
|
|
783
|
+
errors.push({
|
|
784
|
+
path,
|
|
785
|
+
message: `FieldType '${fieldTypeRef}' not found! `,
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
return {
|
|
792
|
+
pass: errors.length === 0,
|
|
793
|
+
errors,
|
|
794
|
+
};
|
|
795
|
+
};
|
|
796
|
+
const validateFactory = (schema) => {
|
|
797
|
+
const ajv = new Ajv__default["default"]({
|
|
798
|
+
// https://github.com/ajv-validator/ajv/issues/1417
|
|
799
|
+
strictTuples: false,
|
|
800
|
+
allowMatchingProperties: false,
|
|
801
|
+
schemas: [
|
|
802
|
+
allSchema,
|
|
803
|
+
appSchema,
|
|
804
|
+
modulesSchema,
|
|
805
|
+
frontendBaseSchema,
|
|
806
|
+
triggerSchema,
|
|
807
|
+
webtriggerSchema,
|
|
808
|
+
functionSchema,
|
|
809
|
+
customFieldSchema,
|
|
810
|
+
customFieldTypeSchema,
|
|
811
|
+
resourcesSchema,
|
|
812
|
+
tablesSchema,
|
|
813
|
+
localesSchema,
|
|
814
|
+
],
|
|
815
|
+
});
|
|
816
|
+
AjvKeywords__default["default"](ajv);
|
|
817
|
+
return (json) => {
|
|
818
|
+
const validate = ajv.getSchema(schema);
|
|
819
|
+
const pass = validate === null || validate === void 0 ? void 0 : validate(json);
|
|
820
|
+
const errors = validate === null || validate === void 0 ? void 0 : validate.errors;
|
|
821
|
+
return {
|
|
822
|
+
pass,
|
|
823
|
+
errors: errors
|
|
824
|
+
? lodash.map(errors, error => ({
|
|
825
|
+
path: error.instancePath,
|
|
826
|
+
message: error.message,
|
|
827
|
+
}))
|
|
828
|
+
: null,
|
|
829
|
+
};
|
|
830
|
+
};
|
|
831
|
+
};
|
|
832
|
+
const validateAll = (json) => {
|
|
833
|
+
const { pass: schemaPass, errors } = validateFactory('http://proxima.com/schemas/all.json')(json);
|
|
834
|
+
if (!schemaPass) {
|
|
835
|
+
return { pass: schemaPass, errors };
|
|
836
|
+
}
|
|
837
|
+
// 校验一下需要的引用是否存在
|
|
838
|
+
return validateResource(json);
|
|
839
|
+
};
|
|
840
|
+
validateFactory('http://proxima.com/schemas/app.json');
|
|
841
|
+
validateFactory('http://proxima.com/schemas/modules/index.json');
|
|
842
|
+
validateFactory('http://proxima.com/schemas/resources.json');
|
|
843
|
+
validateFactory('http://proxima.com/schemas/tables.json');
|
|
844
|
+
validateFactory('http://proxima.com/schemas/locales.json');
|
|
845
|
+
|
|
119
846
|
class Manifest {
|
|
120
847
|
constructor(manifestString) {
|
|
121
848
|
this.manifest = yaml.parse(manifestString);
|
|
@@ -216,6 +943,13 @@ class Manifest {
|
|
|
216
943
|
});
|
|
217
944
|
return [...fileNames];
|
|
218
945
|
}
|
|
946
|
+
/**
|
|
947
|
+
* 校验manifest
|
|
948
|
+
* @returns
|
|
949
|
+
*/
|
|
950
|
+
validate() {
|
|
951
|
+
return validateAll(this.getManifest());
|
|
952
|
+
}
|
|
219
953
|
}
|
|
220
954
|
|
|
221
955
|
const getManifest = async () => {
|
|
@@ -242,7 +976,7 @@ var run$2 = async ({ outputDir, inputDir, prod, copyFiles, zip }) => {
|
|
|
242
976
|
start: 'start bundle',
|
|
243
977
|
error: 'bundle failed',
|
|
244
978
|
succeed: 'bundle success',
|
|
245
|
-
}, () => bundleApp({ outputDir, inputDir, manifest, mode: prod ?
|
|
979
|
+
}, () => bundleApp({ outputDir, inputDir, manifest, mode: prod ? MODE.PROD : MODE.DEV }));
|
|
246
980
|
// package
|
|
247
981
|
await execActionWithSpinner({
|
|
248
982
|
start: 'start package',
|
|
@@ -495,11 +1229,11 @@ class DockerService {
|
|
|
495
1229
|
|
|
496
1230
|
const build = (functionFiles, inputDir, outputDir) => {
|
|
497
1231
|
for (const fileName of functionFiles) {
|
|
498
|
-
|
|
1232
|
+
bundle({
|
|
499
1233
|
inputDir,
|
|
500
1234
|
outputDir,
|
|
501
1235
|
fileName,
|
|
502
|
-
mode:
|
|
1236
|
+
mode: MODE.DEV,
|
|
503
1237
|
});
|
|
504
1238
|
}
|
|
505
1239
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@giteeteam/apps-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Giteeteam Apps cli",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dev": "tsc -w",
|
|
28
28
|
"build": "rm -rf dist && rollup -c",
|
|
29
29
|
"prepublish": "pnpm build",
|
|
30
|
+
"prepack": "pnpm build",
|
|
30
31
|
"unlink": "yarn unlink",
|
|
31
32
|
"link": "chmod +x ./dist/index.js && yarn link && yarn link '@giteeteam/apps-cli' -g",
|
|
32
33
|
"build-link": "pnpm build && yarn run link"
|
|
@@ -37,25 +38,29 @@
|
|
|
37
38
|
"registry": "https://registry.npmjs.org/"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@giteeteam/apps-bundler": "^0.2.3",
|
|
41
41
|
"@giteeteam/apps-manifest": "^0.2.1",
|
|
42
|
+
"@rollup/plugin-commonjs": "^22.0.0",
|
|
43
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
42
44
|
"archiver": "^5.3.1",
|
|
43
45
|
"chalk": "^4.1.2",
|
|
44
46
|
"chokidar": "^3.5.3",
|
|
45
47
|
"commander": "^9.3.0",
|
|
46
48
|
"dotenv": "^16.0.2",
|
|
49
|
+
"esbuild": "^0.16.11",
|
|
47
50
|
"execa": "^5.1.1",
|
|
48
51
|
"fs-extra": "^10.1.0",
|
|
49
52
|
"inquirer": "^8.2.4",
|
|
50
53
|
"ora": "^5.4.1",
|
|
54
|
+
"rollup": "^2.79.0",
|
|
51
55
|
"simple-git": "^3.7.1",
|
|
52
56
|
"yaml": "^2.1.1"
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|
|
59
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
55
60
|
"@types/archiver": "^5.3.1",
|
|
56
61
|
"@types/fs-extra": "^9.0.13",
|
|
57
62
|
"@types/inquirer": "^8.2.1",
|
|
58
|
-
"@types/uuid": "^8.3.4"
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
"@types/uuid": "^8.3.4",
|
|
64
|
+
"rollup-plugin-typescript2": "^0.31.2"
|
|
65
|
+
}
|
|
61
66
|
}
|