lincd-cli 0.2.9 → 0.2.11
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/defaults/app-with-backend/backend/server.js +2 -1
- package/defaults/app-with-backend/frontend/src/App.scss +0 -3
- package/defaults/app-with-backend/frontend/src/App.tsx +12 -8
- package/defaults/app-with-backend/frontend/src/package.ts +3 -0
- package/defaults/app-with-backend/lincd.config.js +4 -0
- package/defaults/app-with-backend/package.json +2 -1
- package/lib/cli-methods.js +1391 -0
- package/lib/cli.js +25 -1446
- package/lib/config-webpack.js +121 -34
- package/lib/utils.js +90 -18
- package/package.json +1 -1
- package/yarn-error.log +0 -12933
package/lib/cli.js
CHANGED
|
@@ -1,89 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
-
function step(op) {
|
|
17
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
-
while (_) try {
|
|
19
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
-
switch (op[0]) {
|
|
22
|
-
case 0: case 1: t = op; break;
|
|
23
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
-
default:
|
|
27
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
-
if (t[2]) _.ops.pop();
|
|
32
|
-
_.trys.pop(); continue;
|
|
33
|
-
}
|
|
34
|
-
op = body.call(thisArg, _);
|
|
35
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
40
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
41
|
-
if (!m) return o;
|
|
42
|
-
var i = m.call(o), r, ar = [], e;
|
|
43
|
-
try {
|
|
44
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
45
|
-
}
|
|
46
|
-
catch (error) { e = { error: error }; }
|
|
47
|
-
finally {
|
|
48
|
-
try {
|
|
49
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
50
|
-
}
|
|
51
|
-
finally { if (e) throw e.error; }
|
|
52
|
-
}
|
|
53
|
-
return ar;
|
|
54
|
-
};
|
|
55
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
56
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
57
|
-
if (ar || !(i in from)) {
|
|
58
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
59
|
-
ar[i] = from[i];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
63
|
-
};
|
|
64
3
|
exports.__esModule = true;
|
|
65
|
-
var
|
|
4
|
+
var cli_methods_1 = require("./cli-methods");
|
|
66
5
|
require('require-extensions');
|
|
67
6
|
var program = require('commander');
|
|
68
|
-
var exec = require('child_process').exec;
|
|
69
|
-
var chalk = require('chalk');
|
|
70
7
|
var fs = require('fs-extra');
|
|
71
8
|
var path = require('path');
|
|
72
|
-
var glob = require('glob');
|
|
73
|
-
var variables = {};
|
|
74
|
-
var open = require('open');
|
|
75
|
-
var gruntConfig;
|
|
76
9
|
program
|
|
77
10
|
.command('create-app')
|
|
78
11
|
.action(function (name) {
|
|
79
|
-
return createApp(name);
|
|
12
|
+
return (0, cli_methods_1.createApp)(name);
|
|
80
13
|
})
|
|
81
14
|
.description('Creates a new folder with all the required files for a LINCD app')
|
|
82
15
|
.argument('<name>', 'the name of your LINCD app. To use spaces, wrap the name in double quotes.');
|
|
83
16
|
program
|
|
84
17
|
.command('create-package')
|
|
85
18
|
.action(function (name, uriBase) {
|
|
86
|
-
return createPackage(name, uriBase);
|
|
19
|
+
return (0, cli_methods_1.createPackage)(name, uriBase);
|
|
87
20
|
})
|
|
88
21
|
.description('Create a new folder with all the required files for a new LINCD package')
|
|
89
22
|
.argument('<name>', 'The name of the package. Will be used as package name in package.json')
|
|
@@ -91,82 +24,85 @@ program
|
|
|
91
24
|
program
|
|
92
25
|
.command('create-shape')
|
|
93
26
|
.action(function (name, uriBase) {
|
|
94
|
-
return createShape(name);
|
|
27
|
+
return (0, cli_methods_1.createShape)(name);
|
|
95
28
|
})
|
|
96
29
|
.description('Creates a new ShapeClass file for your package. Execute this from your package folder.')
|
|
97
30
|
.argument('<name>', 'The name of the shape. Will be used for the file name and the class name');
|
|
98
31
|
program
|
|
99
32
|
.command('create-component')
|
|
100
33
|
.action(function (name, uriBase) {
|
|
101
|
-
return createComponent(name);
|
|
34
|
+
return (0, cli_methods_1.createComponent)(name);
|
|
102
35
|
})
|
|
103
36
|
.description('Creates a new Component file for your package. Execute this from your package folder.')
|
|
104
37
|
.argument('<name>', 'The name of the component. Will be used for the file name and the export name');
|
|
105
38
|
program
|
|
106
39
|
.command('create-set-component')
|
|
107
40
|
.action(function (name, uriBase) {
|
|
108
|
-
return createSetComponent(name);
|
|
41
|
+
return (0, cli_methods_1.createSetComponent)(name);
|
|
109
42
|
})
|
|
110
43
|
.description('Creates a new SetComponent file for your package. Execute this from your package folder.')
|
|
111
44
|
.argument('<name>', 'The name of the component. Will be used for the file name and the export name');
|
|
112
45
|
program
|
|
113
46
|
.command('create-ontology')
|
|
114
47
|
.action(function (prefix, uriBase) {
|
|
115
|
-
return createOntology(prefix, uriBase);
|
|
48
|
+
return (0, cli_methods_1.createOntology)(prefix, uriBase);
|
|
116
49
|
})
|
|
117
50
|
.description('Creates a new ontology file for your package. Execute this from your package folder.')
|
|
118
51
|
.argument('<suggested-prefix>', 'The suggested prefix for your ontology. Also the shorthand code used for the file name and the exported ontology object')
|
|
119
52
|
.argument('[uribase]', "Optional argument to set the URI base for the URI's of all entities in your ontology. Leave blank to use the URI's provided by lincd.org once you register this package");
|
|
53
|
+
program.command('app [action]', { hidden: true }).action(function () {
|
|
54
|
+
(0, cli_methods_1.register)('http://localhost:4101');
|
|
55
|
+
});
|
|
120
56
|
program.command('register-local', { hidden: true }).action(function () {
|
|
121
|
-
register('http://localhost:4101');
|
|
57
|
+
(0, cli_methods_1.register)('http://localhost:4101');
|
|
122
58
|
});
|
|
123
59
|
program.command('register-dev', { hidden: true }).action(function () {
|
|
124
|
-
register('https://dev-registry.lincd.org');
|
|
60
|
+
(0, cli_methods_1.register)('https://dev-registry.lincd.org');
|
|
125
61
|
});
|
|
126
62
|
program
|
|
127
63
|
.command('register')
|
|
128
64
|
.action(function () {
|
|
129
|
-
register('https://registry.lincd.org');
|
|
65
|
+
(0, cli_methods_1.register)('https://registry.lincd.org');
|
|
130
66
|
})
|
|
131
67
|
.description('Register (a new version of) this package to the LINCD registry. If successful your package will appear on www.lincd.org');
|
|
132
68
|
program
|
|
133
69
|
.command('info')
|
|
134
70
|
.action(function () {
|
|
135
|
-
var ownPackage = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
|
|
71
|
+
var ownPackage = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
136
72
|
console.log(ownPackage.version);
|
|
137
73
|
console.log('Running from: ' + __dirname);
|
|
138
74
|
})
|
|
139
75
|
.description("Log the version of this tool and the path that it's running from");
|
|
140
76
|
program.command('build [target] [target2]', { isDefault: true }).action(function (target, target2) {
|
|
141
|
-
buildPackage(target, target2);
|
|
77
|
+
(0, cli_methods_1.buildPackage)(target, target2);
|
|
142
78
|
});
|
|
143
79
|
program.command('publish-updated').action(function () {
|
|
144
|
-
return publishUpdated();
|
|
80
|
+
return (0, cli_methods_1.publishUpdated)();
|
|
145
81
|
});
|
|
146
82
|
program.command('status').action(function () {
|
|
147
83
|
//log which packages need to be published
|
|
148
|
-
return publishUpdated(true).then(function () {
|
|
84
|
+
return (0, cli_methods_1.publishUpdated)(true).then(function () {
|
|
149
85
|
//log which packages need to be build
|
|
150
|
-
return buildUpdated(undefined, '', '', true);
|
|
86
|
+
return (0, cli_methods_1.buildUpdated)(undefined, '', '', true);
|
|
151
87
|
});
|
|
152
88
|
});
|
|
153
89
|
program.command('build-updated [target] [target2]').action(function (target, target2) {
|
|
154
|
-
return buildUpdated(1, target, target2);
|
|
90
|
+
return (0, cli_methods_1.buildUpdated)(1, target, target2);
|
|
155
91
|
});
|
|
156
92
|
program.command('build-updated-since [num-commits-back] [target] [target2]').action(function (back, target, target2) {
|
|
157
|
-
return buildUpdated(back, target, target2);
|
|
93
|
+
return (0, cli_methods_1.buildUpdated)(back, target, target2);
|
|
158
94
|
});
|
|
159
95
|
program.command('build-all [target] [target2] [target3]').action(function (target, target2, target3) {
|
|
160
|
-
buildAll(target, target2, target3);
|
|
96
|
+
(0, cli_methods_1.buildAll)(target, target2, target3);
|
|
161
97
|
});
|
|
162
98
|
program.command('all [action] [filter] [filter-value]').action(function (command, filter, filterValue) {
|
|
163
|
-
executeCommandForEachPackage(getLincdPackages(), command, filter, filterValue);
|
|
99
|
+
(0, cli_methods_1.executeCommandForEachPackage)((0, cli_methods_1.getLincdPackages)(), command, filter, filterValue);
|
|
164
100
|
});
|
|
165
101
|
// program.command('all-except [excludedSpaces] [action]').action((excludedSpaces, command) => {
|
|
166
102
|
// executeCommandForEachModule(getLincdModules(), command, null, excludedSpaces);
|
|
167
103
|
// });
|
|
168
104
|
program.command('dev [target] [mode]').action(function (target, mode) {
|
|
169
|
-
developPackage(target, mode);
|
|
105
|
+
(0, cli_methods_1.developPackage)(target, mode);
|
|
170
106
|
});
|
|
171
107
|
program
|
|
172
108
|
.command('package')
|
|
@@ -180,7 +116,7 @@ program
|
|
|
180
116
|
.filter(function (a) { return a && true; })
|
|
181
117
|
.join(' ')
|
|
182
118
|
: null;
|
|
183
|
-
executeCommandForPackage(name, fullCommand);
|
|
119
|
+
(0, cli_methods_1.executeCommandForPackage)(name, fullCommand);
|
|
184
120
|
})
|
|
185
121
|
.alias('p')
|
|
186
122
|
.alias('pkg')
|
|
@@ -191,1363 +127,6 @@ program
|
|
|
191
127
|
.argument('[command]', 'the lincd command you want to execute. Like dev or build')
|
|
192
128
|
.argument('[args...]', 'the additional arguments of that command');
|
|
193
129
|
program.command('add-capacitor').action(function () {
|
|
194
|
-
addCapacitor();
|
|
130
|
+
(0, cli_methods_1.addCapacitor)();
|
|
195
131
|
});
|
|
196
|
-
function logHelp() {
|
|
197
|
-
execp('yarn lincd help');
|
|
198
|
-
}
|
|
199
|
-
function log() {
|
|
200
|
-
var messages = [];
|
|
201
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
202
|
-
messages[_i] = arguments[_i];
|
|
203
|
-
}
|
|
204
|
-
messages.forEach(function (message) {
|
|
205
|
-
console.log(chalk.cyan('Info: ') + message);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
function progressUpdate(message) {
|
|
209
|
-
process.stdout.write(' \r');
|
|
210
|
-
process.stdout.write(message + '\r');
|
|
211
|
-
}
|
|
212
|
-
function debugInfo() {
|
|
213
|
-
var messages = [];
|
|
214
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
215
|
-
messages[_i] = arguments[_i];
|
|
216
|
-
}
|
|
217
|
-
// messages.forEach((message) => {
|
|
218
|
-
// console.log(chalk.cyan('Info: ') + message);
|
|
219
|
-
// });
|
|
220
|
-
//@TODO: let packages also use lincd.config.json? instead of gruntfile...
|
|
221
|
-
// that way we can read "analyse" here and see if we need to log debug info
|
|
222
|
-
// if(!gruntConfig)
|
|
223
|
-
// {
|
|
224
|
-
// gruntConfig = getGruntConfig();
|
|
225
|
-
// console.log(gruntConfig);
|
|
226
|
-
// process.exit();
|
|
227
|
-
// }
|
|
228
|
-
if (gruntConfig && gruntConfig.analyse === true) {
|
|
229
|
-
messages.forEach(function (message) {
|
|
230
|
-
console.log(chalk.cyan('Info: ') + message);
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function warn() {
|
|
235
|
-
var messages = [];
|
|
236
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
237
|
-
messages[_i] = arguments[_i];
|
|
238
|
-
}
|
|
239
|
-
messages.forEach(function (message) {
|
|
240
|
-
console.log(chalk.magenta('Warning: ') + message);
|
|
241
|
-
// console.log(chalk.red(message));
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
function developPackage(target, mode) {
|
|
245
|
-
if (!target)
|
|
246
|
-
target = 'es6';
|
|
247
|
-
if (mode !== 'production')
|
|
248
|
-
mode = '';
|
|
249
|
-
else if (target !== 'es6')
|
|
250
|
-
log('target must be es6 when developing for production');
|
|
251
|
-
if (target == 'es5' || target == 'es6') {
|
|
252
|
-
// log('> Starting continuous development build for '+target+' target')
|
|
253
|
-
log('starting continuous development build');
|
|
254
|
-
log('grunt dev' + (target ? '-' + target : '') + (mode ? '-' + mode : '') + ' --color');
|
|
255
|
-
var command = exec('grunt dev' + (target ? '-' + target : '') + (mode ? '-' + mode : '') + ' --color');
|
|
256
|
-
command.stdout.pipe(process.stdout);
|
|
257
|
-
command.stderr.pipe(process.stderr);
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
console.warn('unknown build target. Use es5 or es6');
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
function checkWorkspaces(rootPath, workspaces, res) {
|
|
264
|
-
// console.log('checking workspaces at '+rootPath+": "+workspaces.toString());
|
|
265
|
-
if (workspaces.packages) {
|
|
266
|
-
workspaces = workspaces.packages;
|
|
267
|
-
}
|
|
268
|
-
workspaces.forEach(function (workspace) {
|
|
269
|
-
var workspacePath = path.join(rootPath, workspace.replace('/*', ''));
|
|
270
|
-
if (workspace.indexOf('/*') !== -1) {
|
|
271
|
-
// console.log(workspacePath);
|
|
272
|
-
if (fs.existsSync(workspacePath)) {
|
|
273
|
-
var folders = fs.readdirSync(workspacePath);
|
|
274
|
-
folders.forEach(function (folder) {
|
|
275
|
-
if (folder !== './' && folder !== '../') {
|
|
276
|
-
checkPackagePath(rootPath, path.join(workspacePath, folder), res);
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
checkPackagePath(rootPath, workspacePath, res);
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
function checkPackagePath(rootPath, packagePath, res) {
|
|
287
|
-
var packageJsonPath = path.join(packagePath, 'package.json');
|
|
288
|
-
// console.log('checking '+packagePath);
|
|
289
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
290
|
-
var pack = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
291
|
-
//some packages are not true lincd packages, but we still want them to be re-built automatically. This is what lincd_util is for
|
|
292
|
-
if (pack && pack.workspaces) {
|
|
293
|
-
checkWorkspaces(packagePath, pack.workspaces, res);
|
|
294
|
-
}
|
|
295
|
-
else if (pack && pack.lincd === true) {
|
|
296
|
-
res.push({
|
|
297
|
-
path: packagePath,
|
|
298
|
-
packageName: pack.name
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
function runOnPackagesGroupedByDependencies(lincdPackages, onBuildStack, onStackEnd) {
|
|
304
|
-
var _this = this;
|
|
305
|
-
var dependencies = new Map();
|
|
306
|
-
//get dependencies of each package
|
|
307
|
-
var leastDependentPackage;
|
|
308
|
-
lincdPackages.forEach(function (pkg) {
|
|
309
|
-
var pack = (0, utils_1.getPackageJSON)(pkg.path);
|
|
310
|
-
if (pack) {
|
|
311
|
-
//get lincd related dependencies and get the actual package details from the package map by removing '@dacore/' from the package name
|
|
312
|
-
var packageDependencies = Object.keys(pack.dependencies)
|
|
313
|
-
.filter(function (dependency) { return lincdPackages.has(dependency); })
|
|
314
|
-
.map(function (dependency) {
|
|
315
|
-
return lincdPackages.has(dependency) ? lincdPackages.get(dependency) : dependency;
|
|
316
|
-
});
|
|
317
|
-
// console.log(package.packageName,packageDependencies.map())
|
|
318
|
-
dependencies.set(pkg, packageDependencies);
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
dependencies.forEach(function (PackageDependencies, pkg) {
|
|
322
|
-
if (!PackageDependencies.some(function (dependency) {
|
|
323
|
-
return typeof dependency !== 'string' && lincdPackages.has(dependency.packageName);
|
|
324
|
-
})) {
|
|
325
|
-
leastDependentPackage = pkg;
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
var startStack = [leastDependentPackage];
|
|
329
|
-
var done = new Set();
|
|
330
|
-
var results = [];
|
|
331
|
-
var runStack = function (stack) { return __awaiter(_this, void 0, void 0, function () {
|
|
332
|
-
var runFunction, stackPromise, stackResults;
|
|
333
|
-
return __generator(this, function (_a) {
|
|
334
|
-
switch (_a.label) {
|
|
335
|
-
case 0:
|
|
336
|
-
runFunction = onBuildStack(stack, dependencies);
|
|
337
|
-
stackPromise = Promise.all(stack.map(function (pck) {
|
|
338
|
-
// p = p.then(() => {
|
|
339
|
-
return runFunction(pck)["catch"](function (_a) {
|
|
340
|
-
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
341
|
-
warn('Uncaught exception whilst running parallel function on ' + pck.packageName, error.message);
|
|
342
|
-
// warn(chalk.red(pck.packageName+' failed:'));
|
|
343
|
-
// console.log(stdout);
|
|
344
|
-
})
|
|
345
|
-
.then(function (res) {
|
|
346
|
-
done.add(pck);
|
|
347
|
-
return res;
|
|
348
|
-
});
|
|
349
|
-
}));
|
|
350
|
-
return [4 /*yield*/, stackPromise];
|
|
351
|
-
case 1:
|
|
352
|
-
stackResults = _a.sent();
|
|
353
|
-
results = results.concat(stackResults);
|
|
354
|
-
//clear stack for next round
|
|
355
|
-
stack = [];
|
|
356
|
-
//find those packages who have all their dependencies already built and add them to the stack
|
|
357
|
-
lincdPackages.forEach(function (pkg) {
|
|
358
|
-
var deps = dependencies.get(pkg);
|
|
359
|
-
//if the package is not done yet
|
|
360
|
-
//but every dependency is now done OR was not something we can build (some @dacore dependencies may not be local)
|
|
361
|
-
if (!done.has(pkg) &&
|
|
362
|
-
deps.every(function (dependency) {
|
|
363
|
-
return typeof dependency !== 'string' && (done.has(dependency) || !lincdPackages.has(dependency.packageName));
|
|
364
|
-
})) {
|
|
365
|
-
stack.push(pkg);
|
|
366
|
-
}
|
|
367
|
-
// else if(!done.has(package))
|
|
368
|
-
// {
|
|
369
|
-
// console.log(chalk.red(package+' not yet'))
|
|
370
|
-
// console.log('UNMET DEPS: '+deps.filter(dependency => !done.has(dependency)).join(" "))
|
|
371
|
-
// }
|
|
372
|
-
});
|
|
373
|
-
//if more to be built, iterate
|
|
374
|
-
if (stack.length > 0) {
|
|
375
|
-
return [2 /*return*/, runStack(stack)];
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
onStackEnd(results.filter(Boolean));
|
|
379
|
-
}
|
|
380
|
-
return [2 /*return*/];
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
}); };
|
|
384
|
-
//starts the process
|
|
385
|
-
runStack(startStack);
|
|
386
|
-
}
|
|
387
|
-
function buildAll(target, target2, target3) {
|
|
388
|
-
var _this = this;
|
|
389
|
-
console.log('Building all LINCD packages of this repository in order of dependencies');
|
|
390
|
-
var lincdPackages = getLocalLincdPackageMap();
|
|
391
|
-
var startFrom;
|
|
392
|
-
//by default start building
|
|
393
|
-
var building = true;
|
|
394
|
-
//option to start from a specific package in the stack
|
|
395
|
-
if (target == 'from') {
|
|
396
|
-
startFrom = target2;
|
|
397
|
-
//if we have a startFrom, then we havnt started the build process yet
|
|
398
|
-
building = startFrom ? false : true;
|
|
399
|
-
//clear targets
|
|
400
|
-
target = '';
|
|
401
|
-
target2 = '';
|
|
402
|
-
console.log(chalk.blue('Will skip builds until ' + startFrom));
|
|
403
|
-
// return async (pkg) => {};
|
|
404
|
-
}
|
|
405
|
-
if (target2 == 'from') {
|
|
406
|
-
startFrom = target3;
|
|
407
|
-
//if we have a startFrom, then we havnt started the build process yet
|
|
408
|
-
building = startFrom ? false : true;
|
|
409
|
-
//clear targets
|
|
410
|
-
target2 = '';
|
|
411
|
-
target3 = '';
|
|
412
|
-
console.log(chalk.blue('Will skip builds until ' + startFrom));
|
|
413
|
-
// return async (pkg) => {};
|
|
414
|
-
}
|
|
415
|
-
var done = new Set();
|
|
416
|
-
var failedModules = [];
|
|
417
|
-
progressUpdate(lincdPackages.size + ' packages left');
|
|
418
|
-
var packagesLeft = lincdPackages.size;
|
|
419
|
-
// let packagesLeft = lincdPackages.size - done.size;
|
|
420
|
-
runOnPackagesGroupedByDependencies(lincdPackages, function (packageGroup, dependencies) {
|
|
421
|
-
if (done.size > 0) {
|
|
422
|
-
debugInfo(chalk.magenta('\n-------\nThese packages are next, since all their dependencies have now been build:'));
|
|
423
|
-
// log(stack);
|
|
424
|
-
}
|
|
425
|
-
debugInfo('Now building: ' + chalk.blue(packageGroup.map(function (i) { return i.packageName; })));
|
|
426
|
-
return function (pkg) { return __awaiter(_this, void 0, void 0, function () {
|
|
427
|
-
var command;
|
|
428
|
-
return __generator(this, function (_a) {
|
|
429
|
-
//if we're skipping builds until a certain package
|
|
430
|
-
if (!building) {
|
|
431
|
-
//if the package name matches the package we're supposed to start from then start building packages
|
|
432
|
-
if (pkg.packageName == startFrom || pkg.packageName == startFrom) {
|
|
433
|
-
building = true;
|
|
434
|
-
}
|
|
435
|
-
//else still waiting for the package
|
|
436
|
-
else {
|
|
437
|
-
log(chalk.blue('skipping ' + pkg.packageName));
|
|
438
|
-
command = Promise.resolve(true);
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
//unless told otherwise, build the package
|
|
442
|
-
if (!command) {
|
|
443
|
-
command = execPromise('cd ' + pkg.path + ' && yarn lincd build' + (target ? ' ' + target : '') + (target2 ? ' ' + target2 : ''), false, false, {}, false);
|
|
444
|
-
debugInfo(chalk.cyan('Building ' + pkg.packageName));
|
|
445
|
-
}
|
|
446
|
-
return [2 /*return*/, command["catch"](function (_a) {
|
|
447
|
-
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
448
|
-
//this prints out the webpack output, including the build errors
|
|
449
|
-
warn('Failed to build ' + pkg.packageName);
|
|
450
|
-
console.log(stdout);
|
|
451
|
-
failedModules.push(pkg.packageName);
|
|
452
|
-
var dependentModules = getDependentPackages(dependencies, pkg);
|
|
453
|
-
if (dependentModules.length > 0) {
|
|
454
|
-
printBuildResults(failedModules, done);
|
|
455
|
-
console.log(chalk.magenta('Stopping build process because an error occurred whilst building ' +
|
|
456
|
-
pkg.packageName +
|
|
457
|
-
', which ' +
|
|
458
|
-
dependentModules.length +
|
|
459
|
-
' other packages depend on.')); //"+dependentModules.map(d => d.packageName).join(", ")));
|
|
460
|
-
console.log(chalk.cyanBright('tip ') +
|
|
461
|
-
'Run ' +
|
|
462
|
-
chalk.green("lincd build-all from ".concat(pkg.packageName)) +
|
|
463
|
-
' to build only the remaining packages'); //"+dependentModules.map(d => d.packageName).join(", ")));
|
|
464
|
-
process.exit(1);
|
|
465
|
-
}
|
|
466
|
-
})
|
|
467
|
-
.then(function (res) {
|
|
468
|
-
log(chalk.green('Built ' + pkg.packageName));
|
|
469
|
-
done.add(pkg);
|
|
470
|
-
packagesLeft--;
|
|
471
|
-
// log(chalk.magenta(packagesLeft + ' packages left'));
|
|
472
|
-
process.stdout.write(packagesLeft + ' packages left\r');
|
|
473
|
-
if (packagesLeft == 0) {
|
|
474
|
-
printBuildResults(failedModules, done);
|
|
475
|
-
}
|
|
476
|
-
return res;
|
|
477
|
-
})];
|
|
478
|
-
});
|
|
479
|
-
}); };
|
|
480
|
-
}, function (dependencies) {
|
|
481
|
-
//if no more packages to build but we never started building...
|
|
482
|
-
if (!building) {
|
|
483
|
-
console.log(chalk.red('Could not find the package to start from. Please provide a correct package name or package name to build from'));
|
|
484
|
-
}
|
|
485
|
-
else {
|
|
486
|
-
//Detecting cyclical dependencies that caused some packages not to be build
|
|
487
|
-
var first_1 = true;
|
|
488
|
-
lincdPackages.forEach(function (pkg) {
|
|
489
|
-
if (!done.has(pkg)) {
|
|
490
|
-
var deps = dependencies.get(pkg);
|
|
491
|
-
if (first_1) {
|
|
492
|
-
console.log(chalk.red('CYCLICAL DEPENDENCIES? - could not build some packages because they depend on each other.'));
|
|
493
|
-
first_1 = false;
|
|
494
|
-
}
|
|
495
|
-
//print the cyclical dependencies
|
|
496
|
-
console.log(chalk.red(pkg.packageName) +
|
|
497
|
-
' depends on ' +
|
|
498
|
-
deps
|
|
499
|
-
.filter(function (dependency) {
|
|
500
|
-
return typeof dependency !== 'string';
|
|
501
|
-
})
|
|
502
|
-
.map(function (d) {
|
|
503
|
-
return done.has(d) ? d.packageName : chalk.red(d.packageName);
|
|
504
|
-
})
|
|
505
|
-
.join(', '));
|
|
506
|
-
//also print some information why these packages have not been moved into the stack
|
|
507
|
-
var stringDependencies = deps.filter(function (d) { return typeof d === 'string'; });
|
|
508
|
-
if (stringDependencies.length > 0) {
|
|
509
|
-
console.log(chalk.red('And it depends on these package(s) - which seem not to be proper packages :' +
|
|
510
|
-
stringDependencies.join(', ')));
|
|
511
|
-
console.log(chalk.red('Could you remove this from dependencies? Should it be a devDependency?'));
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
function getDependentPackages(dependencies, pkg) {
|
|
519
|
-
var dependentModules = [];
|
|
520
|
-
dependencies.forEach(function (dModuleDependencies, dModule) {
|
|
521
|
-
if (dModuleDependencies.indexOf(pkg) !== -1) {
|
|
522
|
-
dependentModules.push(dModule);
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
return dependentModules;
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* Returns a map of the packages that this repository manages (so no packages found through the workspaces who's path contains ../ )
|
|
529
|
-
* @param rootPath
|
|
530
|
-
*/
|
|
531
|
-
function getLocalLincdPackageMap(rootPath) {
|
|
532
|
-
if (rootPath === void 0) { rootPath = './'; }
|
|
533
|
-
var map = new Map();
|
|
534
|
-
getLincdPackages(rootPath).forEach(function (pkg) {
|
|
535
|
-
if (pkg.path.indexOf('../') === -1 && pkg.path.indexOf('..\\') === -1) {
|
|
536
|
-
// console.log(package.path);
|
|
537
|
-
map.set(pkg.packageName, pkg);
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
return map;
|
|
541
|
-
}
|
|
542
|
-
function getLocalLincdModules(rootPath) {
|
|
543
|
-
if (rootPath === void 0) { rootPath = './'; }
|
|
544
|
-
return getLincdPackages(rootPath).filter(function (pkg) {
|
|
545
|
-
return pkg.path.indexOf('..\\') === -1;
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
function getLincdPackages(rootPath) {
|
|
549
|
-
if (rootPath === void 0) { rootPath = process.cwd(); }
|
|
550
|
-
var pack = (0, utils_1.getPackageJSON)();
|
|
551
|
-
if (!pack || !pack.workspaces) {
|
|
552
|
-
for (var i = 0; i <= 3; i++) {
|
|
553
|
-
rootPath = path.join.apply(path, __spreadArray([process.cwd()], __read(Array(i).fill('..')), false));
|
|
554
|
-
pack = (0, utils_1.getPackageJSON)(rootPath);
|
|
555
|
-
if (pack && pack.workspaces) {
|
|
556
|
-
// log('Found workspace at '+packagePath);
|
|
557
|
-
break;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
if (!pack || !pack.workspaces) {
|
|
562
|
-
warn(chalk.red('Could not find package workspaces. Make sure you run this command from a yarn workspace.'));
|
|
563
|
-
logHelp();
|
|
564
|
-
process.exit();
|
|
565
|
-
}
|
|
566
|
-
// console.log(pack.workspaces);
|
|
567
|
-
var res = [];
|
|
568
|
-
checkWorkspaces(rootPath, pack.workspaces, res);
|
|
569
|
-
return res;
|
|
570
|
-
}
|
|
571
|
-
function setVariable(name, replacement) {
|
|
572
|
-
//prepare name for regexp
|
|
573
|
-
name = name.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
574
|
-
variables[name] = replacement;
|
|
575
|
-
}
|
|
576
|
-
function execp(cmd, log, allowError, options) {
|
|
577
|
-
if (log === void 0) { log = false; }
|
|
578
|
-
if (allowError === void 0) { allowError = false; }
|
|
579
|
-
if (options === void 0) { options = {}; }
|
|
580
|
-
// opts || (opts = {});
|
|
581
|
-
if (log)
|
|
582
|
-
console.log(chalk.cyan(cmd));
|
|
583
|
-
return new Promise(function (resolve, reject) {
|
|
584
|
-
var child = exec(cmd, options);
|
|
585
|
-
child.stdout.pipe(process.stdout);
|
|
586
|
-
child.stderr.pipe(process.stderr);
|
|
587
|
-
// process.stdin.pipe(child.stdin);
|
|
588
|
-
child.on('close', function (code) {
|
|
589
|
-
if (code === 0) {
|
|
590
|
-
resolve(null);
|
|
591
|
-
}
|
|
592
|
-
else {
|
|
593
|
-
reject();
|
|
594
|
-
}
|
|
595
|
-
// console.log('killing child');
|
|
596
|
-
// child.kill('SIGHUP');
|
|
597
|
-
// resolve(code);
|
|
598
|
-
});
|
|
599
|
-
// child.on('data', function (result) {
|
|
600
|
-
// // if (log)
|
|
601
|
-
// // {
|
|
602
|
-
// // console.log(result);
|
|
603
|
-
// // }
|
|
604
|
-
// resolve(result);
|
|
605
|
-
// console.log('resolve data');
|
|
606
|
-
//
|
|
607
|
-
// });
|
|
608
|
-
child.on('error', function (err) {
|
|
609
|
-
if (!allowError) {
|
|
610
|
-
// console.log('reject err');
|
|
611
|
-
reject(err);
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
else if (log) {
|
|
615
|
-
console.warn(err);
|
|
616
|
-
}
|
|
617
|
-
// console.log('resolve err');
|
|
618
|
-
resolve(null);
|
|
619
|
-
});
|
|
620
|
-
child.on('exit', function (code, signal) {
|
|
621
|
-
if (code !== 0) {
|
|
622
|
-
reject('Child process exited with error code ' + code);
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
// console.log('resolve exit');
|
|
626
|
-
resolve(null);
|
|
627
|
-
});
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
function execPromise(command, log, allowError, options, pipeOutput) {
|
|
631
|
-
if (log === void 0) { log = false; }
|
|
632
|
-
if (allowError === void 0) { allowError = false; }
|
|
633
|
-
if (pipeOutput === void 0) { pipeOutput = false; }
|
|
634
|
-
return new Promise(function (resolve, reject) {
|
|
635
|
-
if (log)
|
|
636
|
-
console.log(chalk.cyan(command));
|
|
637
|
-
var child = exec(command, options, function (error, stdout, stderr) {
|
|
638
|
-
if (error) {
|
|
639
|
-
if (!allowError) {
|
|
640
|
-
reject({ error: error, stdout: stdout, stderr: stderr });
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
else if (log) {
|
|
644
|
-
console.warn(error);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
var result = stdout.trim();
|
|
648
|
-
if (log) {
|
|
649
|
-
// console.log(chalk"RESOLVING "+command);
|
|
650
|
-
console.log(result);
|
|
651
|
-
// console.log('ERRORS:'+(result.indexOf('Aborted due to warnings') !== -1));
|
|
652
|
-
// console.log('stderr:'+stderr);
|
|
653
|
-
}
|
|
654
|
-
resolve(result);
|
|
655
|
-
});
|
|
656
|
-
if (pipeOutput) {
|
|
657
|
-
child.stdout.pipe(process.stdout);
|
|
658
|
-
child.stderr.pipe(process.stderr);
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
var replaceVariablesInFile = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
663
|
-
var fileContent, newContent;
|
|
664
|
-
return __generator(this, function (_a) {
|
|
665
|
-
switch (_a.label) {
|
|
666
|
-
case 0: return [4 /*yield*/, fs.readFile(filePath, 'utf8')];
|
|
667
|
-
case 1:
|
|
668
|
-
fileContent = _a.sent();
|
|
669
|
-
newContent = replaceCurlyVariables(fileContent);
|
|
670
|
-
return [2 /*return*/, fs.writeFile(filePath, newContent)];
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
}); };
|
|
674
|
-
var replaceCurlyVariables = function (string) {
|
|
675
|
-
// var reg = new RegExp('\\$\\{'+key+'\\}','g');
|
|
676
|
-
for (var key in variables) {
|
|
677
|
-
string = string.replace(new RegExp('\\$\\{' + key + '\\}', 'g'), variables[key]);
|
|
678
|
-
}
|
|
679
|
-
return string;
|
|
680
|
-
};
|
|
681
|
-
var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1); };
|
|
682
|
-
var camelCase = function (str) {
|
|
683
|
-
var string = str.replace(/[^A-Za-z0-9]/g, ' ').split(' ');
|
|
684
|
-
if (string.length > 1) {
|
|
685
|
-
return string.reduce(function (result, word) { return result + capitalize(word); });
|
|
686
|
-
}
|
|
687
|
-
return str;
|
|
688
|
-
};
|
|
689
|
-
var createOntology = function (prefix, uriBase, basePath) {
|
|
690
|
-
if (basePath === void 0) { basePath = process.cwd(); }
|
|
691
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
692
|
-
var targetFolder, _a, hyphenName, camelCaseName, underscoreName, targetFile, targetDataFile, targetDataFile2, indexPath;
|
|
693
|
-
return __generator(this, function (_b) {
|
|
694
|
-
switch (_b.label) {
|
|
695
|
-
case 0:
|
|
696
|
-
if (!prefix) {
|
|
697
|
-
console.warn('Please provide a suggested prefix as the first argument');
|
|
698
|
-
return [2 /*return*/];
|
|
699
|
-
}
|
|
700
|
-
targetFolder = ensureFolderExists(basePath, 'src', 'ontologies');
|
|
701
|
-
if (!uriBase) {
|
|
702
|
-
uriBase = 'http://lincd.org/ont/' + prefix;
|
|
703
|
-
}
|
|
704
|
-
setVariable('uri_base', uriBase);
|
|
705
|
-
_a = setNameVariables(prefix), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
|
|
706
|
-
//copy ontology accessor file
|
|
707
|
-
log("Creating files for ontology '" + prefix + "'");
|
|
708
|
-
targetFile = path.join(targetFolder, hyphenName + '.ts');
|
|
709
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'ontologies', 'example-ontology.ts'), targetFile);
|
|
710
|
-
targetDataFile = path.join(targetFolder, '..', 'data', hyphenName + '.json');
|
|
711
|
-
targetDataFile2 = path.join(targetFolder, '..', 'data', hyphenName + '.json.d.ts');
|
|
712
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json'), targetDataFile);
|
|
713
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'package', 'src', 'data', 'example-ontology.json.d.ts'), targetDataFile2);
|
|
714
|
-
return [4 /*yield*/, replaceVariablesInFiles(targetFile, targetDataFile, targetDataFile2)];
|
|
715
|
-
case 1:
|
|
716
|
-
_b.sent();
|
|
717
|
-
indexPath = addLineToIndex("import './ontologies/".concat(hyphenName, "';"), 'ontologies');
|
|
718
|
-
log("Prepared a new ontology data files in ".concat(chalk.magenta(targetDataFile.replace(basePath, ''))), "And an ontology accessor file in ".concat(chalk.magenta(targetFile.replace(basePath, ''))), "Added an import of this file from ".concat(chalk.magenta(indexPath)));
|
|
719
|
-
return [2 /*return*/];
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
};
|
|
724
|
-
var addLineToIndex = function (line, insertMatchString) {
|
|
725
|
-
//import ontology in index
|
|
726
|
-
var indexPath = ['index.ts', 'index.tsx']
|
|
727
|
-
.map(function (f) { return path.join('src', f); })
|
|
728
|
-
.find(function (indexFileName) {
|
|
729
|
-
return fs.existsSync(indexFileName);
|
|
730
|
-
});
|
|
731
|
-
if (indexPath) {
|
|
732
|
-
var indexContents = fs.readFileSync(indexPath, 'utf-8');
|
|
733
|
-
var lines = indexContents.split(/\n/g);
|
|
734
|
-
var newContents = void 0;
|
|
735
|
-
for (var key in lines) {
|
|
736
|
-
if (lines[key].indexOf(insertMatchString) !== -1) {
|
|
737
|
-
//remove lines after this line and insert new line in its place
|
|
738
|
-
lines[key] += "\n".concat(line);
|
|
739
|
-
newContents = lines.join('\n');
|
|
740
|
-
// log("Found at "+key,lines,newContents);
|
|
741
|
-
break;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
if (!newContents) {
|
|
745
|
-
newContents = indexContents + "\n".concat(line);
|
|
746
|
-
// log("Added at end",newContents);
|
|
747
|
-
}
|
|
748
|
-
fs.writeFileSync(indexPath, newContents);
|
|
749
|
-
}
|
|
750
|
-
return indexPath;
|
|
751
|
-
};
|
|
752
|
-
var replaceVariablesInFiles = function () {
|
|
753
|
-
var files = [];
|
|
754
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
755
|
-
files[_i] = arguments[_i];
|
|
756
|
-
}
|
|
757
|
-
return Promise.all(files.map(function (file) {
|
|
758
|
-
return replaceVariablesInFile(file);
|
|
759
|
-
}));
|
|
760
|
-
};
|
|
761
|
-
var replaceVariablesInFilesWithRoot = function (root) {
|
|
762
|
-
var files = [];
|
|
763
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
764
|
-
files[_i - 1] = arguments[_i];
|
|
765
|
-
}
|
|
766
|
-
return replaceVariablesInFiles.apply(void 0, __spreadArray([], __read(files.map(function (f) { return path.join(root, f); })), false));
|
|
767
|
-
};
|
|
768
|
-
var hasYarnInstalled = function () {
|
|
769
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
770
|
-
var version;
|
|
771
|
-
return __generator(this, function (_a) {
|
|
772
|
-
switch (_a.label) {
|
|
773
|
-
case 0: return [4 /*yield*/, execPromise('yarn --version')["catch"](function (err) {
|
|
774
|
-
console.log('yarn probably not working');
|
|
775
|
-
return '';
|
|
776
|
-
})];
|
|
777
|
-
case 1:
|
|
778
|
-
version = (_a.sent());
|
|
779
|
-
return [2 /*return*/, version.toString().match(/[0-9]+/)];
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
});
|
|
783
|
-
};
|
|
784
|
-
var ensureFolderExists = function () {
|
|
785
|
-
var folders = [];
|
|
786
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
787
|
-
folders[_i] = arguments[_i];
|
|
788
|
-
}
|
|
789
|
-
var target;
|
|
790
|
-
folders.forEach(function (folder) {
|
|
791
|
-
target = target ? path.join(target, folder) : path.join(folder);
|
|
792
|
-
if (!fs.existsSync(target)) {
|
|
793
|
-
fs.mkdirSync(target);
|
|
794
|
-
}
|
|
795
|
-
});
|
|
796
|
-
return target;
|
|
797
|
-
/*let targetFolder = path.join(...folders);
|
|
798
|
-
let parentDirectory = folders.slice(0, folders.length - 1);
|
|
799
|
-
if (!fs.existsSync(targetFolder)) {
|
|
800
|
-
if (fs.existsSync(path.join(...parentDirectory))) {
|
|
801
|
-
fs.mkdirSync(targetFolder);
|
|
802
|
-
} else {
|
|
803
|
-
warn(
|
|
804
|
-
`Please run this command from the root of your package. This command expects ${parentDirectory.toString()} to exists from that folder`,
|
|
805
|
-
);
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
return targetFolder;*/
|
|
809
|
-
};
|
|
810
|
-
var setNameVariables = function (name) {
|
|
811
|
-
var hyphenName = name.replace(/[-_\s]+/g, '-');
|
|
812
|
-
var camelCaseName = camelCase(name); //some-package --> someModule
|
|
813
|
-
var underscoreName = name.replace(/[-\s]+/g, '_');
|
|
814
|
-
//longer similar variables names should come before the shorter ones
|
|
815
|
-
setVariable('underscore_name', underscoreName);
|
|
816
|
-
setVariable('hyphen_name', hyphenName);
|
|
817
|
-
setVariable('camel_name', camelCaseName);
|
|
818
|
-
setVariable('name', name);
|
|
819
|
-
return { hyphenName: hyphenName, camelCaseName: camelCaseName, underscoreName: underscoreName };
|
|
820
|
-
};
|
|
821
|
-
var createShape = function (name, basePath) {
|
|
822
|
-
if (basePath === void 0) { basePath = process.cwd(); }
|
|
823
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
824
|
-
var targetFolder, _a, hyphenName, camelCaseName, underscoreName, targetFile, indexPath;
|
|
825
|
-
return __generator(this, function (_b) {
|
|
826
|
-
switch (_b.label) {
|
|
827
|
-
case 0:
|
|
828
|
-
targetFolder = ensureFolderExists(basePath, 'src', 'shapes');
|
|
829
|
-
_a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
|
|
830
|
-
//copy default shape file
|
|
831
|
-
log("Creating files for shape '" + name + "'");
|
|
832
|
-
targetFile = path.join(targetFolder, hyphenName + '.ts');
|
|
833
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'shape.ts'), targetFile);
|
|
834
|
-
//replace variables in some of the copied files
|
|
835
|
-
return [4 /*yield*/, replaceVariablesInFiles(targetFile)];
|
|
836
|
-
case 1:
|
|
837
|
-
//replace variables in some of the copied files
|
|
838
|
-
_b.sent();
|
|
839
|
-
indexPath = addLineToIndex("import './shapes/".concat(hyphenName, "';"), 'shapes');
|
|
840
|
-
log("Created a new shape class template in ".concat(chalk.magenta(targetFile.replace(basePath, ''))), "Added an import of this file from ".concat(chalk.magenta(indexPath)));
|
|
841
|
-
return [2 /*return*/];
|
|
842
|
-
}
|
|
843
|
-
});
|
|
844
|
-
});
|
|
845
|
-
};
|
|
846
|
-
var createSetComponent = function (name, basePath) {
|
|
847
|
-
if (basePath === void 0) { basePath = process.cwd(); }
|
|
848
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
849
|
-
var targetFolder, _a, hyphenName, camelCaseName, underscoreName, targetFile, targetFile2, indexPath;
|
|
850
|
-
return __generator(this, function (_b) {
|
|
851
|
-
switch (_b.label) {
|
|
852
|
-
case 0:
|
|
853
|
-
targetFolder = ensureFolderExists(basePath, 'src', 'components');
|
|
854
|
-
_a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
|
|
855
|
-
//copy default shape file
|
|
856
|
-
log("Creating files for set component '" + name + "'");
|
|
857
|
-
targetFile = path.join(targetFolder, hyphenName + '.tsx');
|
|
858
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'set-component.tsx'), targetFile);
|
|
859
|
-
targetFile2 = path.join(targetFolder, hyphenName + '.scss');
|
|
860
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'component.scss'), targetFile2);
|
|
861
|
-
//replace variables in some of the copied files
|
|
862
|
-
return [4 /*yield*/, replaceVariablesInFiles(targetFile, targetFile2)];
|
|
863
|
-
case 1:
|
|
864
|
-
//replace variables in some of the copied files
|
|
865
|
-
_b.sent();
|
|
866
|
-
indexPath = addLineToIndex("import './components/".concat(hyphenName, "';"), 'components');
|
|
867
|
-
log("Created a new set component in ".concat(chalk.magenta(targetFile.replace(basePath, ''))), "Created a new stylesheet in ".concat(chalk.magenta(targetFile2.replace(basePath, ''))), "Added an import of this file from ".concat(chalk.magenta(indexPath)));
|
|
868
|
-
return [2 /*return*/];
|
|
869
|
-
}
|
|
870
|
-
});
|
|
871
|
-
});
|
|
872
|
-
};
|
|
873
|
-
var createComponent = function (name, basePath) {
|
|
874
|
-
if (basePath === void 0) { basePath = process.cwd(); }
|
|
875
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
876
|
-
var targetFolder, _a, hyphenName, camelCaseName, underscoreName, targetFile, targetFile2, indexPath;
|
|
877
|
-
return __generator(this, function (_b) {
|
|
878
|
-
switch (_b.label) {
|
|
879
|
-
case 0:
|
|
880
|
-
targetFolder = ensureFolderExists(basePath, 'src', 'components');
|
|
881
|
-
_a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
|
|
882
|
-
//copy default shape file
|
|
883
|
-
log("Creating files for component '" + name + "'");
|
|
884
|
-
targetFile = path.join(targetFolder, hyphenName + '.tsx');
|
|
885
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'component.tsx'), targetFile);
|
|
886
|
-
targetFile2 = path.join(targetFolder, hyphenName + '.scss');
|
|
887
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'component.scss'), targetFile2);
|
|
888
|
-
//replace variables in some of the copied files
|
|
889
|
-
return [4 /*yield*/, replaceVariablesInFiles(targetFile, targetFile2)];
|
|
890
|
-
case 1:
|
|
891
|
-
//replace variables in some of the copied files
|
|
892
|
-
_b.sent();
|
|
893
|
-
indexPath = addLineToIndex("import './components/".concat(hyphenName, "';"), 'components');
|
|
894
|
-
log("Created a new component template in ".concat(chalk.magenta(targetFile.replace(basePath, ''))), "Created component stylesheet template in ".concat(chalk.magenta(targetFile2.replace(basePath, ''))), "Added an import of this file from ".concat(chalk.magenta(indexPath)));
|
|
895
|
-
return [2 /*return*/];
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
});
|
|
899
|
-
};
|
|
900
|
-
var createPackage = function (name, uriBase, basePath) {
|
|
901
|
-
if (basePath === void 0) { basePath = process.cwd(); }
|
|
902
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
903
|
-
var _a, packageName, scope, cleanPackageName, targetFolder, _b, hyphenName, camelCaseName, underscoreName, version, installCommand;
|
|
904
|
-
return __generator(this, function (_c) {
|
|
905
|
-
switch (_c.label) {
|
|
906
|
-
case 0:
|
|
907
|
-
//if ran with npx, basePath will be the root directory of the repository, even if we're executing from a sub folder (the root directory is where node_modules lives and package.json with workspaces)
|
|
908
|
-
//so we manually find a packages folder, if it exists we go into that.
|
|
909
|
-
if (fs.existsSync(path.join(basePath, 'packages'))) {
|
|
910
|
-
basePath = path.join(basePath, 'packages');
|
|
911
|
-
}
|
|
912
|
-
if (!name) {
|
|
913
|
-
console.warn('Please provide a name as the first argument');
|
|
914
|
-
return [2 /*return*/];
|
|
915
|
-
}
|
|
916
|
-
_a = __read(name.match(/(@[\w\-]+\/)?([\w\-]+)/), 3), packageName = _a[0], scope = _a[1], cleanPackageName = _a[2];
|
|
917
|
-
targetFolder = ensureFolderExists(basePath, cleanPackageName);
|
|
918
|
-
if (!uriBase) {
|
|
919
|
-
uriBase = 'http://lincd.org/ont/' + name;
|
|
920
|
-
}
|
|
921
|
-
setVariable('uri_base', uriBase);
|
|
922
|
-
//find @scope and the next part between 2 slashes after
|
|
923
|
-
//so @dacore/some-mod/lib/file.js
|
|
924
|
-
// --> match[0] = @dacore/some-mod
|
|
925
|
-
// --> match[1] = @dacore
|
|
926
|
-
// --> match[2] = some-mod
|
|
927
|
-
//but save full scoped package name under ${package_name}
|
|
928
|
-
setVariable('package_name', name);
|
|
929
|
-
//extra variable for clarity (will be same as 'name')
|
|
930
|
-
setVariable('output_file_name', name);
|
|
931
|
-
_b = setNameVariables(cleanPackageName), hyphenName = _b.hyphenName, camelCaseName = _b.camelCaseName, underscoreName = _b.underscoreName;
|
|
932
|
-
log("Creating new LINCD package '" + name + "'");
|
|
933
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'package'), targetFolder);
|
|
934
|
-
//replace variables in some of the copied files
|
|
935
|
-
return [4 /*yield*/, Promise.all([
|
|
936
|
-
'src/index.ts',
|
|
937
|
-
'package.json',
|
|
938
|
-
'Gruntfile.js',
|
|
939
|
-
'src/package.ts',
|
|
940
|
-
'src/shapes/ExampleShapeClass.ts',
|
|
941
|
-
'src/ontologies/example-ontology.ts',
|
|
942
|
-
'src/data/example-ontology.json',
|
|
943
|
-
]
|
|
944
|
-
.map(function (f) { return path.join(targetFolder, f); })
|
|
945
|
-
.map(function (file) {
|
|
946
|
-
return replaceVariablesInFile(file);
|
|
947
|
-
}))];
|
|
948
|
-
case 1:
|
|
949
|
-
//replace variables in some of the copied files
|
|
950
|
-
_c.sent();
|
|
951
|
-
//rename these to a file name similar to the pkg name
|
|
952
|
-
[
|
|
953
|
-
'src/ontologies/example-ontology.ts',
|
|
954
|
-
'src/data/example-ontology.json',
|
|
955
|
-
'src/data/example-ontology.json.d.ts',
|
|
956
|
-
].forEach(function (f) {
|
|
957
|
-
var parts = f.split('/');
|
|
958
|
-
var newParts = __spreadArray([], __read(parts), false);
|
|
959
|
-
var _a = __read(newParts.pop().split('.')), name = _a[0], extensions = _a.slice(1);
|
|
960
|
-
var newName = hyphenName + '.' + extensions.join('.');
|
|
961
|
-
console.log('rename ', path.join(targetFolder, f), path.join.apply(path, __spreadArray(__spreadArray([targetFolder], __read(newParts), false), [newName], false)));
|
|
962
|
-
fs.renameSync(path.join(targetFolder, f), path.join.apply(path, __spreadArray(__spreadArray([targetFolder], __read(newParts), false), [newName], false)));
|
|
963
|
-
});
|
|
964
|
-
return [4 /*yield*/, execPromise('yarn --version')["catch"](function (err) {
|
|
965
|
-
console.log('yarn probably not working');
|
|
966
|
-
return '';
|
|
967
|
-
})];
|
|
968
|
-
case 2:
|
|
969
|
-
version = (_c.sent());
|
|
970
|
-
installCommand = version.toString().match(/[0-9]+/) ? 'yarn install' : 'npm install';
|
|
971
|
-
return [4 /*yield*/, execp("cd ".concat(targetFolder, " && ").concat(installCommand, " && npm exec lincd build"), true)["catch"](function (err) {
|
|
972
|
-
console.warn('Could not install dependencies');
|
|
973
|
-
})];
|
|
974
|
-
case 3:
|
|
975
|
-
_c.sent();
|
|
976
|
-
log("Prepared a new LINCD package in ".concat(chalk.magenta(targetFolder)), "Run ".concat(chalk.blueBright('yarn build'), " from this directory to build once"), "Or ".concat(chalk.blueBright('yarn dev'), " to continuously rebuild on file changes"));
|
|
977
|
-
return [2 /*return*/];
|
|
978
|
-
}
|
|
979
|
-
});
|
|
980
|
-
});
|
|
981
|
-
};
|
|
982
|
-
var createApp = function (name, basePath) {
|
|
983
|
-
if (basePath === void 0) { basePath = process.cwd(); }
|
|
984
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
985
|
-
var _a, hyphenName, camelCaseName, underscoreName, targetFolder, hasYarn, installCommand;
|
|
986
|
-
return __generator(this, function (_b) {
|
|
987
|
-
switch (_b.label) {
|
|
988
|
-
case 0:
|
|
989
|
-
if (!name) {
|
|
990
|
-
console.warn('Please provide a name as the first argument');
|
|
991
|
-
}
|
|
992
|
-
_a = setNameVariables(name), hyphenName = _a.hyphenName, camelCaseName = _a.camelCaseName, underscoreName = _a.underscoreName;
|
|
993
|
-
targetFolder = path.join(basePath, hyphenName);
|
|
994
|
-
if (!fs.existsSync(targetFolder)) {
|
|
995
|
-
fs.mkdirSync(targetFolder);
|
|
996
|
-
}
|
|
997
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'app-with-backend'), targetFolder);
|
|
998
|
-
fs.renameSync(path.join(targetFolder, '.yarnrc.yml.template'), path.join(targetFolder, '.yarnrc.yml'));
|
|
999
|
-
// fs.copySync(path.join(__dirname, '..', 'defaults', 'app'), targetFolder);
|
|
1000
|
-
log("Creating new LINCD application '" + name + "'");
|
|
1001
|
-
//replace variables in some copied files
|
|
1002
|
-
replaceVariablesInFilesWithRoot(targetFolder, 'package.json', 'frontend/src/App.tsx', 'frontend/src/App.scss.json', 'frontend/src/components/Spinner.scss.json');
|
|
1003
|
-
return [4 /*yield*/, hasYarnInstalled()];
|
|
1004
|
-
case 1:
|
|
1005
|
-
hasYarn = _b.sent();
|
|
1006
|
-
installCommand = hasYarn ? 'yarn install' : 'npm install';
|
|
1007
|
-
return [4 /*yield*/, execp("cd ".concat(hyphenName, " && ").concat(installCommand), true)["catch"](function (err) {
|
|
1008
|
-
console.warn('Could not install dependencies or start application');
|
|
1009
|
-
})];
|
|
1010
|
-
case 2:
|
|
1011
|
-
_b.sent();
|
|
1012
|
-
log("Your LINCD App is ready at ".concat(chalk.blueBright(targetFolder)), "To start, run\n".concat(chalk.blueBright("cd ".concat(hyphenName)), " and then ").concat(chalk.blueBright((hasYarn ? 'yarn' : 'npm') + ' start')));
|
|
1013
|
-
return [2 /*return*/];
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
1016
|
-
});
|
|
1017
|
-
};
|
|
1018
|
-
var getNextVersion = function (version) {
|
|
1019
|
-
var parts = version.split('.');
|
|
1020
|
-
return parts[0] + '.' + parts[1] + '.' + (parseInt(parts[2]) + 1).toString();
|
|
1021
|
-
};
|
|
1022
|
-
var getNextMajorVersion = function (version) {
|
|
1023
|
-
var parts = version.split('.');
|
|
1024
|
-
return (parseInt(parts[0]) + 1).toString() + '.0.0';
|
|
1025
|
-
};
|
|
1026
|
-
var getNextMinorVersion = function (version) {
|
|
1027
|
-
var parts = version.split('.');
|
|
1028
|
-
return parts[0] + '.' + (parseInt(parts[1]) + 1).toString() + '.0';
|
|
1029
|
-
};
|
|
1030
|
-
var buildFailed = function (output) {
|
|
1031
|
-
return output.indexOf('Aborted due to warnings') !== -1 && output.indexOf('Command failed') !== -1;
|
|
1032
|
-
};
|
|
1033
|
-
/*program.command('shapes').action(async () => {
|
|
1034
|
-
//we've imported require-extensions from npm so that we can use this
|
|
1035
|
-
//we want to avoid nodejs tripping up over @import commands in css files
|
|
1036
|
-
require.extensions['.scss'] = function (sourcecode, filename) {
|
|
1037
|
-
return {};
|
|
1038
|
-
};
|
|
1039
|
-
require.extensions['.css'] = function (sourcecode, filename) {
|
|
1040
|
-
return {};
|
|
1041
|
-
};
|
|
1042
|
-
|
|
1043
|
-
if (fs.existsSync(process.cwd() + '/package.json')) {
|
|
1044
|
-
var pack = JSON.parse(
|
|
1045
|
-
fs.readFileSync(process.cwd() + '/package.json', 'utf8'),
|
|
1046
|
-
);
|
|
1047
|
-
let packageName = pack.name;
|
|
1048
|
-
|
|
1049
|
-
//just making sure the library is loaded in correct order because circular references are currently happening when importing BlankNode before NamedNode for example
|
|
1050
|
-
// require('lincd');
|
|
1051
|
-
//TODO: replace with actual index file from package.json, or tsconfig
|
|
1052
|
-
let indexExports = require(process.cwd() + '/lib/index.js');
|
|
1053
|
-
if(indexExports.packageExports)
|
|
1054
|
-
{
|
|
1055
|
-
let shapeJSONLD = await getShapesJSONLD(indexExports.packageExports);
|
|
1056
|
-
console.log(indexExports.packageExports);
|
|
1057
|
-
console.log(shapeJSONLD);
|
|
1058
|
-
console.log(chalk.bold(chalk.green(packageName+'/dist/shapes.json')));
|
|
1059
|
-
return fs.writeFile(path.join('dist', 'shapes.json'), shapeJSONLD);
|
|
1060
|
-
}
|
|
1061
|
-
else
|
|
1062
|
-
{
|
|
1063
|
-
console.warn("Invalid LINCD package. Index file should export a packageExports object. See examples.")
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
} else {
|
|
1067
|
-
console.warn('Not a project');
|
|
1068
|
-
}
|
|
1069
|
-
});*/
|
|
1070
|
-
var register = function (registryURL) {
|
|
1071
|
-
if (fs.existsSync(process.cwd() + '/package.json')) {
|
|
1072
|
-
var pack = JSON.parse(fs.readFileSync(process.cwd() + '/package.json', 'utf8'));
|
|
1073
|
-
var version = pack.version;
|
|
1074
|
-
var packageName = pack.name;
|
|
1075
|
-
// let author = pack.author;
|
|
1076
|
-
// let description = pack.description;
|
|
1077
|
-
//
|
|
1078
|
-
// let authorName = pack.author;
|
|
1079
|
-
// if (pack.author.name) {
|
|
1080
|
-
// authorName = pack.author.name;
|
|
1081
|
-
// }
|
|
1082
|
-
console.log(chalk.cyan('registering package ' + packageName + ' ' + version + ' in the LINCD registry'));
|
|
1083
|
-
return fetch(registryURL + '/register', {
|
|
1084
|
-
method: 'POST',
|
|
1085
|
-
headers: {
|
|
1086
|
-
Accept: 'application/json, text/plain, */*',
|
|
1087
|
-
'Content-Type': 'application/json'
|
|
1088
|
-
},
|
|
1089
|
-
body: JSON.stringify({ package: packageName, version: version })
|
|
1090
|
-
})
|
|
1091
|
-
.then(function (res) { return res.json(); })
|
|
1092
|
-
.then(function (json) {
|
|
1093
|
-
if (json.error) {
|
|
1094
|
-
console.log(chalk.red('Response: ' + json.error));
|
|
1095
|
-
}
|
|
1096
|
-
else if (json.result) {
|
|
1097
|
-
console.log(chalk.blueBright('Response: ') + json.result);
|
|
1098
|
-
if (json.warning) {
|
|
1099
|
-
console.log(chalk.red('Warning: ') + json.warning);
|
|
1100
|
-
}
|
|
1101
|
-
}
|
|
1102
|
-
})["catch"](function (err) {
|
|
1103
|
-
console.warn(chalk.red('Warning: ') + 'Could not connect to LINCD registry');
|
|
1104
|
-
});
|
|
1105
|
-
}
|
|
1106
|
-
else {
|
|
1107
|
-
console.warn(chalk.red('Warning:') + ' not found: ' + process.cwd() + '/package.json');
|
|
1108
|
-
}
|
|
1109
|
-
};
|
|
1110
|
-
var buildPackage = function (target, target2, packagePath, logResults) {
|
|
1111
|
-
if (packagePath === void 0) { packagePath = process.cwd(); }
|
|
1112
|
-
if (logResults === void 0) { logResults = true; }
|
|
1113
|
-
if (target == 'production' || target == 'es5' || target == 'es6' || !target) {
|
|
1114
|
-
if (!fs.existsSync(path.join(packagePath, 'Gruntfile.js'))) {
|
|
1115
|
-
console.warn("No Gruntfile found at ".concat(packagePath, "\\Gruntfile.js. Cannot build."));
|
|
1116
|
-
return;
|
|
1117
|
-
}
|
|
1118
|
-
var nodeEnv = '';
|
|
1119
|
-
if (target == 'production') {
|
|
1120
|
-
if (!(target2 == 'es5' || target2 == 'es6' || typeof target2 == 'undefined')) {
|
|
1121
|
-
console.warn('unknown second build target. Use es5 or es6', target2);
|
|
1122
|
-
return;
|
|
1123
|
-
}
|
|
1124
|
-
var isWindows = /^win/.test(process.platform);
|
|
1125
|
-
if (isWindows) {
|
|
1126
|
-
nodeEnv = 'SET NODE_ENV=production&& ';
|
|
1127
|
-
}
|
|
1128
|
-
else {
|
|
1129
|
-
nodeEnv = "NODE_ENV='production' ";
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
if (!target) {
|
|
1133
|
-
target = 'es6';
|
|
1134
|
-
}
|
|
1135
|
-
log('building once: ' +
|
|
1136
|
-
nodeEnv +
|
|
1137
|
-
'grunt build' +
|
|
1138
|
-
(target ? '-' + target : '') +
|
|
1139
|
-
(target2 ? '-' + target2 : '') +
|
|
1140
|
-
' --color');
|
|
1141
|
-
var method = logResults ? execp : execPromise;
|
|
1142
|
-
//execute the command to build the method, and provide the current work directory as option
|
|
1143
|
-
return method(nodeEnv + 'grunt build' + (target ? '-' + target : '') + (target2 ? '-' + target2 : '') + ' --color', false, false, { cwd: packagePath })["catch"](function (err) {
|
|
1144
|
-
process.exit(1);
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
|
-
else {
|
|
1148
|
-
console.warn('unknown build target. Use es5, es6 or production.');
|
|
1149
|
-
}
|
|
1150
|
-
};
|
|
1151
|
-
var getLastBuildTime = function (packagePath) {
|
|
1152
|
-
return getLastModifiedFile(packagePath + '/@(builds|lib|dist)/**/*.js');
|
|
1153
|
-
};
|
|
1154
|
-
var getLastModifiedSourceTime = function (packagePath) {
|
|
1155
|
-
return getLastModifiedFile(packagePath + '/@(src|data|scss)/**/*', {
|
|
1156
|
-
ignore: [packagePath + '/**/*.scss.json', packagePath + '/**/*.d.ts']
|
|
1157
|
-
});
|
|
1158
|
-
};
|
|
1159
|
-
var getLastCommitTime = function (packagePath) {
|
|
1160
|
-
// console.log(`git log -1 --format=%ci -- ${packagePath}`);
|
|
1161
|
-
// process.exit();
|
|
1162
|
-
return execPromise("git log -1 --format=%ci -- ".concat(packagePath))
|
|
1163
|
-
.then(function (result) {
|
|
1164
|
-
var lastCommit = new Date(result);
|
|
1165
|
-
// console.log(packagePath,result,lastCommit);
|
|
1166
|
-
return lastCommit;
|
|
1167
|
-
})["catch"](function (_a) {
|
|
1168
|
-
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1169
|
-
debugInfo(chalk.red('Git error: ') + error.message.toString());
|
|
1170
|
-
return null;
|
|
1171
|
-
});
|
|
1172
|
-
};
|
|
1173
|
-
var getLastModifiedFile = function (filePath, config) {
|
|
1174
|
-
if (config === void 0) { config = {}; }
|
|
1175
|
-
var files = glob.sync(filePath, config);
|
|
1176
|
-
// console.log(files.join(" - "));
|
|
1177
|
-
var lastModifiedName;
|
|
1178
|
-
var lastModified;
|
|
1179
|
-
var lastModifiedTime = 0;
|
|
1180
|
-
files.forEach(function (fileName) {
|
|
1181
|
-
if (fs.lstatSync(fileName).isDirectory()) {
|
|
1182
|
-
// console.log("skipping directory "+fileName);
|
|
1183
|
-
return;
|
|
1184
|
-
}
|
|
1185
|
-
var mtime = fs.statSync(path.join(fileName)).mtime;
|
|
1186
|
-
var modifiedTime = mtime.getTime();
|
|
1187
|
-
if (modifiedTime > lastModifiedTime) {
|
|
1188
|
-
// console.log(fileName,mtime);
|
|
1189
|
-
lastModifiedName = fileName;
|
|
1190
|
-
lastModified = mtime;
|
|
1191
|
-
lastModifiedTime = modifiedTime;
|
|
1192
|
-
}
|
|
1193
|
-
});
|
|
1194
|
-
return { lastModified: lastModified, lastModifiedName: lastModifiedName, lastModifiedTime: lastModifiedTime };
|
|
1195
|
-
};
|
|
1196
|
-
var publishUpdated = function (test) {
|
|
1197
|
-
var _this = this;
|
|
1198
|
-
if (test === void 0) { test = false; }
|
|
1199
|
-
var packages = getLocalLincdModules();
|
|
1200
|
-
var browserCoreBuilt = false;
|
|
1201
|
-
var p = Promise.resolve('');
|
|
1202
|
-
var packagesLeft = packages.length;
|
|
1203
|
-
var results = [];
|
|
1204
|
-
log('Checking which packages need to be published by comparing last published date with last git commit');
|
|
1205
|
-
// p = Promise.all(packages.map((pckg) => {
|
|
1206
|
-
packages.forEach(function (pckg) {
|
|
1207
|
-
p = p
|
|
1208
|
-
.then(function (previousResult) {
|
|
1209
|
-
// progressUpdate(packagesLeft-- + ' packages left. Now checking ' + pckg.packageName);
|
|
1210
|
-
// log('# Checking package ' + pckg.packageName);
|
|
1211
|
-
// log('# Requesting ' + 'yarn info '+pkg.packageName+' --json');
|
|
1212
|
-
// return execPromise('yarn info '+pkg.packageName+' --json').then((output:string) => {
|
|
1213
|
-
// console.log("Will be requesting npm view from this current working directory:\n"+process.cwd());
|
|
1214
|
-
// return execPromise('npm view '+pkg.packageName+' --json').then((output:string) => {
|
|
1215
|
-
var shouldPublish;
|
|
1216
|
-
var pack = (0, utils_1.getPackageJSON)(pckg.path);
|
|
1217
|
-
var version = getNextVersion(pack.version);
|
|
1218
|
-
if (pack.private) {
|
|
1219
|
-
shouldPublish = false;
|
|
1220
|
-
debugInfo(chalk.blue('--> is private, skipping'));
|
|
1221
|
-
return chalk.gray(pckg.packageName + ' is private');
|
|
1222
|
-
// return previousResult + ' ' + chalk.gray(pckg.packageName + ' is private\n');
|
|
1223
|
-
}
|
|
1224
|
-
return execPromise('npm info ' + pckg.packageName + ' --json')
|
|
1225
|
-
.then(function (output) { return __awaiter(_this, void 0, void 0, function () {
|
|
1226
|
-
var info, lastPublish, lastPublishDate, lastCommit, err_1, res, browserModule;
|
|
1227
|
-
return __generator(this, function (_a) {
|
|
1228
|
-
switch (_a.label) {
|
|
1229
|
-
case 0:
|
|
1230
|
-
_a.trys.push([0, 3, , 4]);
|
|
1231
|
-
if (output == '' || output.includes('E404')) {
|
|
1232
|
-
debugInfo('Empty or 404 response from `npm info`. This package was probably not published before');
|
|
1233
|
-
// throw new Error('Empty response from `yarn info`. This pkg was probably not published before');
|
|
1234
|
-
// return;
|
|
1235
|
-
shouldPublish = true;
|
|
1236
|
-
//don't patch the version number (default, see above), use the current version
|
|
1237
|
-
version = pack.version;
|
|
1238
|
-
}
|
|
1239
|
-
else {
|
|
1240
|
-
info = JSON.parse(output);
|
|
1241
|
-
}
|
|
1242
|
-
if (!info) return [3 /*break*/, 2];
|
|
1243
|
-
lastPublish = void 0;
|
|
1244
|
-
//yarn:
|
|
1245
|
-
// let lastPublish = info.data.time[info.data.version];
|
|
1246
|
-
lastPublish = info.time[info.version];
|
|
1247
|
-
lastPublishDate = new Date(lastPublish);
|
|
1248
|
-
return [4 /*yield*/, getLastCommitTime(pckg.path)];
|
|
1249
|
-
case 1:
|
|
1250
|
-
lastCommit = _a.sent();
|
|
1251
|
-
if (!lastCommit) {
|
|
1252
|
-
shouldPublish = false;
|
|
1253
|
-
debugInfo('Could not determine last git commit');
|
|
1254
|
-
// return previousResult + ' ' + chalk.red(pckg.packageName + ' - could not determine last commit\n');
|
|
1255
|
-
return [2 /*return*/, chalk.red(pckg.packageName + ' - could not determine last commit')];
|
|
1256
|
-
}
|
|
1257
|
-
else {
|
|
1258
|
-
//NOTE: removed lastModified, because switching branches will say that the file was modified and cause everything to publish
|
|
1259
|
-
//SO: now you NEED TO commit before it picks up that you should publish
|
|
1260
|
-
shouldPublish = lastPublishDate.getTime() < lastCommit.getTime();
|
|
1261
|
-
// if (shouldPublish) {
|
|
1262
|
-
// log(
|
|
1263
|
-
// lastPublishDate.toDateString() +
|
|
1264
|
-
// ' ' +
|
|
1265
|
-
// lastPublishDate.toTimeString() +
|
|
1266
|
-
// ' published ' +
|
|
1267
|
-
// info.version,
|
|
1268
|
-
// );
|
|
1269
|
-
// log(
|
|
1270
|
-
// lastCommit.toDateString() + ' ' + new Date(lastCommit).toTimeString() + ' source last committed',
|
|
1271
|
-
// );
|
|
1272
|
-
// }
|
|
1273
|
-
}
|
|
1274
|
-
_a.label = 2;
|
|
1275
|
-
case 2: return [3 /*break*/, 4];
|
|
1276
|
-
case 3:
|
|
1277
|
-
err_1 = _a.sent();
|
|
1278
|
-
// var stats = fs.statSync(path.join(packageDirectory));
|
|
1279
|
-
// var files = fs.readdirSync(path.join(packageDirectory,'src'));
|
|
1280
|
-
console.log(chalk.red(pckg.packageName + ' failed: ' + err_1.message + '\n'));
|
|
1281
|
-
console.warn('Returned JSON from npm: ' + output);
|
|
1282
|
-
// return previousResult + ' ' + chalk.red(pckg.packageName + ' failed: ' + err.message + '\n');
|
|
1283
|
-
return [2 /*return*/, chalk.red(pckg.packageName + ' failed: ' + err_1.message)];
|
|
1284
|
-
case 4:
|
|
1285
|
-
if (shouldPublish) {
|
|
1286
|
-
res = publishPackage(pckg, test, info, version);
|
|
1287
|
-
if (pckg.packageName == 'browser-core') {
|
|
1288
|
-
browserCoreBuilt = true;
|
|
1289
|
-
}
|
|
1290
|
-
//when publishing core, also make sure to publish browser-core
|
|
1291
|
-
if (pckg.packageName == 'core' && !browserCoreBuilt) {
|
|
1292
|
-
browserModule = packages.find(function (m) { return m.packageName == 'browser-core'; });
|
|
1293
|
-
return [2 /*return*/, Promise.resolve(res).then(function (previousResult) {
|
|
1294
|
-
log('# Automatically also publishing package browser-core');
|
|
1295
|
-
return publishPackage(browserModule, test);
|
|
1296
|
-
})];
|
|
1297
|
-
}
|
|
1298
|
-
return [2 /*return*/, res];
|
|
1299
|
-
}
|
|
1300
|
-
// return previousResult + ' ' + chalk.green(pckg.packageName + ' latest version is up to date\n');
|
|
1301
|
-
return [2 /*return*/, chalk.green(pckg.packageName + ' latest version is up to date')];
|
|
1302
|
-
}
|
|
1303
|
-
});
|
|
1304
|
-
}); })["catch"](function (_a) {
|
|
1305
|
-
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1306
|
-
if (error) {
|
|
1307
|
-
console.log(error.message);
|
|
1308
|
-
}
|
|
1309
|
-
if (stdout) {
|
|
1310
|
-
console.log(stderr);
|
|
1311
|
-
}
|
|
1312
|
-
if (stderr) {
|
|
1313
|
-
console.log(stderr);
|
|
1314
|
-
}
|
|
1315
|
-
// return previousResult + ' ' + chalk.red(pckg.packageName + ' failed\n');
|
|
1316
|
-
console.warn(chalk.red(pckg.packageName + ' failed'));
|
|
1317
|
-
return chalk.red(pckg.packageName + ' failed');
|
|
1318
|
-
});
|
|
1319
|
-
})
|
|
1320
|
-
.then(function (res) {
|
|
1321
|
-
log(res);
|
|
1322
|
-
results.push(res);
|
|
1323
|
-
})["catch"](function (err) {
|
|
1324
|
-
console.warn(chalk.red(pckg.packageName + ' failed: ' + err.toString()));
|
|
1325
|
-
results.push(chalk.red(pckg.packageName + ' failed: ' + err.toString()));
|
|
1326
|
-
});
|
|
1327
|
-
});
|
|
1328
|
-
return p.then(function () {
|
|
1329
|
-
// if (messages == '')
|
|
1330
|
-
// {
|
|
1331
|
-
// console.log('All published packages are already up-to-date.');
|
|
1332
|
-
// }
|
|
1333
|
-
// else
|
|
1334
|
-
// {
|
|
1335
|
-
console.log('Summary: \n' + results.join('\n'));
|
|
1336
|
-
// }
|
|
1337
|
-
});
|
|
1338
|
-
};
|
|
1339
|
-
var publishPackage = function (pkg, test, info, publishVersion) {
|
|
1340
|
-
if (!publishVersion) {
|
|
1341
|
-
// publishVersion = info ? getNextVersion(info.data.version) : '';
|
|
1342
|
-
publishVersion = info ? getNextVersion(info.version) : '';
|
|
1343
|
-
}
|
|
1344
|
-
if (test) {
|
|
1345
|
-
debugInfo('should publish ' + pkg.packageName + ' ' + publishVersion);
|
|
1346
|
-
}
|
|
1347
|
-
else {
|
|
1348
|
-
console.log(chalk.blue('publishing ' + pkg.packageName + ' ' + publishVersion));
|
|
1349
|
-
}
|
|
1350
|
-
if (!test) {
|
|
1351
|
-
return execPromise("cd ".concat(pkg.path, " && yarn version ").concat(publishVersion, " && yarn npm publish"), true, false, {}, true)
|
|
1352
|
-
.then(function (res) {
|
|
1353
|
-
if (res.indexOf('Aborted due to warnings') !== -1 ||
|
|
1354
|
-
res.indexOf('Could not publish') !== -1 ||
|
|
1355
|
-
res.indexOf("Couldn't publish") !== -1) {
|
|
1356
|
-
console.log(res);
|
|
1357
|
-
return chalk.red(pkg.packageName + ' failed\n');
|
|
1358
|
-
}
|
|
1359
|
-
console.log(chalk.green('Successfully published ' + pkg.path + ' ' + publishVersion));
|
|
1360
|
-
return chalk.green(pkg.packageName + ' published ' + publishVersion + '\n');
|
|
1361
|
-
})["catch"](function (_a) {
|
|
1362
|
-
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1363
|
-
console.log(chalk.red('Failed to publish: ' + error.message));
|
|
1364
|
-
return chalk.red(pkg.packageName + ' failed to publish\n');
|
|
1365
|
-
});
|
|
1366
|
-
}
|
|
1367
|
-
else {
|
|
1368
|
-
//when testing what needs to be published
|
|
1369
|
-
return chalk.blue(pkg.packageName + ' should publish');
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
var buildUpdated = function (back, target, target2, test) {
|
|
1373
|
-
if (test === void 0) { test = false; }
|
|
1374
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1375
|
-
var previousResult, packages, jsonldPkgUpdated, cliPkgUpdated, rebuildAllModules, packagesLeft, p;
|
|
1376
|
-
var _this = this;
|
|
1377
|
-
return __generator(this, function (_a) {
|
|
1378
|
-
switch (_a.label) {
|
|
1379
|
-
case 0:
|
|
1380
|
-
previousResult = '';
|
|
1381
|
-
log(test ? 'Checking which packages need to be rebuild' : 'Building updated packages');
|
|
1382
|
-
packages = getLocalLincdPackageMap();
|
|
1383
|
-
jsonldPkgUpdated = needsRebuilding(packages.get('lincd-jsonld'));
|
|
1384
|
-
cliPkgUpdated = needsRebuilding(packages.get('lincd-cli'));
|
|
1385
|
-
if (!(jsonldPkgUpdated || cliPkgUpdated)) return [3 /*break*/, 2];
|
|
1386
|
-
return [4 /*yield*/, execPromise('yarn build-core', false, false, {}, true)];
|
|
1387
|
-
case 1:
|
|
1388
|
-
_a.sent();
|
|
1389
|
-
_a.label = 2;
|
|
1390
|
-
case 2:
|
|
1391
|
-
rebuildAllModules = false;
|
|
1392
|
-
if (cliPkgUpdated) {
|
|
1393
|
-
rebuildAllModules = true;
|
|
1394
|
-
log(chalk.magenta('Rebuilding all packages because the build tools (lincd-cli) got updated'));
|
|
1395
|
-
}
|
|
1396
|
-
packagesLeft = packages.size;
|
|
1397
|
-
runOnPackagesGroupedByDependencies(packages, function (packageGroup, dependencies) {
|
|
1398
|
-
// console.log('Now checking: ' + chalk.blue(packageGroup.map((i) => i.packageName)));
|
|
1399
|
-
// console.log((packagesLeft) + " packages left.");
|
|
1400
|
-
packagesLeft = packagesLeft - packageGroup.length;
|
|
1401
|
-
return function (pkg) { return __awaiter(_this, void 0, void 0, function () {
|
|
1402
|
-
var needRebuild;
|
|
1403
|
-
return __generator(this, function (_a) {
|
|
1404
|
-
debugInfo('# Checking package ' + pkg.packageName);
|
|
1405
|
-
needRebuild = needsRebuilding(pkg, true);
|
|
1406
|
-
if (pkg.packageName === 'lincd-jsonld' && jsonldPkgUpdated) {
|
|
1407
|
-
needRebuild = true;
|
|
1408
|
-
}
|
|
1409
|
-
// console.log(pkg.path,lastModifiedSource.lastModifiedTime,lastModifiedBundle.lastModifiedTime);
|
|
1410
|
-
// console.log(pkg.path,new Date(lastModifiedSource.lastModified).toString(),new Date(lastModifiedBundle.lastModified).toString());
|
|
1411
|
-
if (needRebuild || rebuildAllModules) {
|
|
1412
|
-
//TODO: when building a pkg, also rebuild all packages that depend on this package.. and iteratively build packages that depend on those packages..
|
|
1413
|
-
// log(packageName+' modified since last commit on '+now.toString());
|
|
1414
|
-
if (test) {
|
|
1415
|
-
debugInfo('Need to build ' + pkg.packageName);
|
|
1416
|
-
return [2 /*return*/, chalk.blue(pkg.packageName + ' should be build')];
|
|
1417
|
-
}
|
|
1418
|
-
log('Building ' + pkg.packageName);
|
|
1419
|
-
return [2 /*return*/, execPromise('cd ' + pkg.path + ' && yarn build' + (target ? ' ' + target : '') + (target2 ? ' ' + target2 : ''))
|
|
1420
|
-
.then(function (res) {
|
|
1421
|
-
debugInfo(chalk.green(pkg.packageName + ' successfully built'));
|
|
1422
|
-
return chalk.green(pkg.packageName + ' built');
|
|
1423
|
-
})["catch"](function (_a) {
|
|
1424
|
-
var error = _a.error, stdout = _a.stdout, stderr = _a.stderr;
|
|
1425
|
-
warn('Failed to build ' + pkg.packageName);
|
|
1426
|
-
console.log(stdout);
|
|
1427
|
-
var dependentModules = getDependentPackages(dependencies, pkg);
|
|
1428
|
-
if (dependentModules.length > 0) {
|
|
1429
|
-
// printBuildResults(failedModules, done);
|
|
1430
|
-
warn(chalk.red(pkg.packageName + ' build failed'));
|
|
1431
|
-
warn('Stopping build-updated process because ' +
|
|
1432
|
-
dependentModules.length +
|
|
1433
|
-
' other packages depend on this package.\n'); //"+dependentModules.map(d => d.packageName).join(", ")));
|
|
1434
|
-
process.exit(1);
|
|
1435
|
-
}
|
|
1436
|
-
})];
|
|
1437
|
-
}
|
|
1438
|
-
return [2 /*return*/];
|
|
1439
|
-
});
|
|
1440
|
-
}); };
|
|
1441
|
-
}, function (results) {
|
|
1442
|
-
if (results.length) {
|
|
1443
|
-
log('Summary:');
|
|
1444
|
-
log(results.join('\n'));
|
|
1445
|
-
}
|
|
1446
|
-
else {
|
|
1447
|
-
log(chalk.green('Nothing to rebuild'));
|
|
1448
|
-
}
|
|
1449
|
-
});
|
|
1450
|
-
return [2 /*return*/];
|
|
1451
|
-
}
|
|
1452
|
-
});
|
|
1453
|
-
});
|
|
1454
|
-
};
|
|
1455
|
-
var needsRebuilding = function (pkg, logDetailsIfTrue) {
|
|
1456
|
-
if (logDetailsIfTrue === void 0) { logDetailsIfTrue = false; }
|
|
1457
|
-
var lastModifiedSource = getLastModifiedSourceTime(pkg.path);
|
|
1458
|
-
var lastModifiedBundle = getLastBuildTime(pkg.path);
|
|
1459
|
-
var result = lastModifiedSource.lastModifiedTime > lastModifiedBundle.lastModifiedTime;
|
|
1460
|
-
if (logDetailsIfTrue) {
|
|
1461
|
-
debugInfo(chalk.cyan('Last modified source: ' +
|
|
1462
|
-
lastModifiedSource.lastModifiedName +
|
|
1463
|
-
' on ' +
|
|
1464
|
-
lastModifiedSource.lastModified.toString()));
|
|
1465
|
-
debugInfo(chalk.cyan('Last build: ' +
|
|
1466
|
-
(lastModifiedBundle && typeof lastModifiedBundle.lastModified !== 'undefined'
|
|
1467
|
-
? lastModifiedBundle.lastModified.toString()
|
|
1468
|
-
: 'never')));
|
|
1469
|
-
}
|
|
1470
|
-
return result;
|
|
1471
|
-
};
|
|
1472
|
-
var printBuildResults = function (failed, done) {
|
|
1473
|
-
log('Successfully built: ' + chalk.green(__spreadArray([], __read(done), false).map(function (m) { return m.packageName; }).join(', ')) + '\n');
|
|
1474
|
-
if (failed.length > 0) {
|
|
1475
|
-
warn('Failed to build: ' + chalk.red(failed.join(', ')) + '\n');
|
|
1476
|
-
}
|
|
1477
|
-
};
|
|
1478
|
-
var executeCommandForEachPackage = function (packages, command, filterMethod, filterValue) {
|
|
1479
|
-
//if a specific set of packages is given
|
|
1480
|
-
if (filterMethod == 'exclude') {
|
|
1481
|
-
//filter packages, so that we only execute on the packages as provided in the command
|
|
1482
|
-
log('Excluding ' + filterValue);
|
|
1483
|
-
filterValue = filterValue.split(',');
|
|
1484
|
-
packages = packages.filter(function (pkg) { return filterValue.indexOf(pkg.packageName) === -1; });
|
|
1485
|
-
}
|
|
1486
|
-
var startFrom;
|
|
1487
|
-
//by default start executing, unless 'from' is given
|
|
1488
|
-
var executing = true;
|
|
1489
|
-
//option to start from a specific pkg in the stack
|
|
1490
|
-
if (filterMethod == 'from') {
|
|
1491
|
-
startFrom = filterValue;
|
|
1492
|
-
if (startFrom) {
|
|
1493
|
-
console.log(chalk.blue('Will skip ahead to ' + startFrom));
|
|
1494
|
-
}
|
|
1495
|
-
var seen_1 = false;
|
|
1496
|
-
packages = packages.filter(function (pkg) {
|
|
1497
|
-
if (!seen_1 && (pkg.packageName == startFrom || pkg.packageName == startFrom)) {
|
|
1498
|
-
seen_1 = true;
|
|
1499
|
-
}
|
|
1500
|
-
return seen_1;
|
|
1501
|
-
});
|
|
1502
|
-
}
|
|
1503
|
-
log("Executing '" +
|
|
1504
|
-
chalk.blueBright(command) +
|
|
1505
|
-
"' on packages " +
|
|
1506
|
-
chalk.magenta(packages.map(function (m) { return m.packageName; }).join(', ')));
|
|
1507
|
-
var p = Promise.resolve(true);
|
|
1508
|
-
packages.forEach(function (pkg) {
|
|
1509
|
-
p = p.then(function () {
|
|
1510
|
-
log('# Package ' + chalk.magenta(pkg.packageName));
|
|
1511
|
-
return execp('cd ' + pkg.path + ' && ' + command);
|
|
1512
|
-
});
|
|
1513
|
-
});
|
|
1514
|
-
return p;
|
|
1515
|
-
};
|
|
1516
|
-
var addCapacitor = function (basePath) {
|
|
1517
|
-
if (basePath === void 0) { basePath = process.cwd(); }
|
|
1518
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1519
|
-
var targetFolder, pack;
|
|
1520
|
-
return __generator(this, function (_a) {
|
|
1521
|
-
switch (_a.label) {
|
|
1522
|
-
case 0:
|
|
1523
|
-
targetFolder = ensureFolderExists(basePath);
|
|
1524
|
-
log('Adding capacitor');
|
|
1525
|
-
fs.copySync(path.join(__dirname, '..', 'defaults', 'app-static'), targetFolder);
|
|
1526
|
-
pack = (0, utils_1.getPackageJSON)(basePath);
|
|
1527
|
-
pack.scripts['build-static'] = 'env-cmd -e static-dev node frontend/scripts/build.js';
|
|
1528
|
-
fs.writeFile(path.resolve(basePath, 'package.json'), JSON.stringify(pack));
|
|
1529
|
-
return [4 /*yield*/, execPromise("yarn add -W -D @capacitor/cli", false, false, null, true)];
|
|
1530
|
-
case 1:
|
|
1531
|
-
_a.sent();
|
|
1532
|
-
return [4 /*yield*/, execPromise("yarn add -W @capacitor/android @capacitor/core @capacitor/geolocation @capacitor/ios @capacitor/push-notifications", false, false, null, true)];
|
|
1533
|
-
case 2:
|
|
1534
|
-
_a.sent();
|
|
1535
|
-
log('Done! Run `yarn build-static` to generate static bundles. Then `yarn cap add android` or `yarn cap add ios`');
|
|
1536
|
-
return [2 /*return*/];
|
|
1537
|
-
}
|
|
1538
|
-
});
|
|
1539
|
-
});
|
|
1540
|
-
};
|
|
1541
|
-
var executeCommandForPackage = function (packageName, command) {
|
|
1542
|
-
var packageDetails = getLincdPackages().find(function (modDetails) {
|
|
1543
|
-
return modDetails.packageName.indexOf(packageName) !== -1 || modDetails.packageName.indexOf(packageName) !== -1;
|
|
1544
|
-
});
|
|
1545
|
-
if (packageDetails) {
|
|
1546
|
-
log("Executing 'cd " + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : '') + "'");
|
|
1547
|
-
return execp('cd ' + packageDetails.path + ' && yarn lincd' + (command ? ' ' + command : ''));
|
|
1548
|
-
}
|
|
1549
|
-
else {
|
|
1550
|
-
warn("Could not find a pkg who's name (partially) matched " + chalk.cyan(packageName));
|
|
1551
|
-
}
|
|
1552
|
-
};
|
|
1553
132
|
program.parse(process.argv);
|