@foal/cli 2.10.2 → 3.0.0-alpha.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/lib/create-secret/create-secret.js +1 -1
- package/lib/generate/file-system.js +47 -47
- package/lib/generate/generators/angular/connect-angular.js +11 -12
- package/lib/generate/generators/app/create-app.js +11 -12
- package/lib/generate/generators/controller/create-controller.js +4 -4
- package/lib/generate/generators/entity/create-entity.js +2 -2
- package/lib/generate/generators/hook/create-hook.js +2 -2
- package/lib/generate/generators/index.d.ts +0 -1
- package/lib/generate/generators/index.js +5 -2
- package/lib/generate/generators/react/connect-react.js +3 -3
- package/lib/generate/generators/rest-api/create-rest-api.js +9 -5
- package/lib/generate/generators/script/create-script.js +1 -1
- package/lib/generate/generators/service/create-service.js +2 -2
- package/lib/generate/generators/vue/connect-vue.js +4 -4
- package/lib/generate/index.js +5 -1
- package/lib/generate/templates/app/.eslintrc.js +13 -14
- package/lib/generate/templates/app/package.json +17 -17
- package/lib/generate/templates/app/package.mongodb.json +13 -13
- package/lib/generate/templates/app/package.mongodb.yaml.json +13 -13
- package/lib/generate/templates/app/package.yaml.json +17 -17
- package/lib/generate/templates/app/src/app/app.controller.ts +0 -5
- package/lib/generate/templates/app/src/app/entities/user.entity.mongodb.ts +3 -14
- package/lib/generate/templates/app/src/app/entities/user.entity.ts +1 -12
- package/lib/generate/templates/app/src/db.ts +24 -0
- package/lib/generate/templates/app/src/e2e/index.ts +10 -2
- package/lib/generate/templates/app/src/index.ts +3 -0
- package/lib/generate/templates/app/src/scripts/create-user.ts +9 -13
- package/lib/generate/templates/app/tsconfig.json +3 -3
- package/lib/generate/templates/entity/entity.mongodb.ts +3 -3
- package/lib/generate/templates/rest-api/controllers/controller.auth.ts +15 -16
- package/lib/generate/templates/rest-api/controllers/controller.spec.auth.ts +27 -21
- package/lib/generate/templates/rest-api/controllers/controller.spec.ts +24 -16
- package/lib/generate/templates/rest-api/controllers/controller.ts +9 -10
- package/lib/generate/templates/script/script.ts +4 -14
- package/lib/generate/utils/init-git-repo.js +2 -2
- package/lib/generate/utils/mkdir-if-does-not-exist.js +2 -2
- package/lib/generate/utils/rm-dir-and-files-if-exist.js +6 -6
- package/lib/index.js +41 -41
- package/lib/rmdir/rmdir.util.js +5 -5
- package/lib/run-script/run-script.js +7 -7
- package/package.json +12 -12
- package/lib/generate/generators/vscode-config/create-vscode-config.d.ts +0 -1
- package/lib/generate/generators/vscode-config/create-vscode-config.js +0 -15
- package/lib/generate/generators/vscode-config/index.d.ts +0 -1
- package/lib/generate/generators/vscode-config/index.js +0 -5
- package/lib/generate/templates/app/ormconfig.js +0 -21
- package/lib/generate/templates/app/src/scripts/create-user.mongodb.ts +0 -38
- package/lib/generate/templates/vscode-config/launch.json +0 -54
- package/lib/generate/templates/vscode-config/tasks.json +0 -25
|
@@ -10,7 +10,7 @@ const util_1 = require("util");
|
|
|
10
10
|
* @returns {Promise<string>} The base64 string.
|
|
11
11
|
*/
|
|
12
12
|
async function createSecret() {
|
|
13
|
-
const buff = await util_1.promisify(crypto_1.randomBytes)(32);
|
|
13
|
+
const buff = await (0, util_1.promisify)(crypto_1.randomBytes)(32);
|
|
14
14
|
return buff.toString('base64');
|
|
15
15
|
}
|
|
16
16
|
exports.createSecret = createSecret;
|
|
@@ -8,17 +8,17 @@ const path_1 = require("path");
|
|
|
8
8
|
// 3p
|
|
9
9
|
const safe_1 = require("colors/safe");
|
|
10
10
|
function rmDirAndFiles(path) {
|
|
11
|
-
const files = fs_1.readdirSync(path);
|
|
11
|
+
const files = (0, fs_1.readdirSync)(path);
|
|
12
12
|
for (const file of files) {
|
|
13
|
-
const stats = fs_1.statSync(path_1.join(path, file));
|
|
13
|
+
const stats = (0, fs_1.statSync)((0, path_1.join)(path, file));
|
|
14
14
|
if (stats.isDirectory()) {
|
|
15
|
-
rmDirAndFiles(path_1.join(path, file));
|
|
15
|
+
rmDirAndFiles((0, path_1.join)(path, file));
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
|
-
fs_1.unlinkSync(path_1.join(path, file));
|
|
18
|
+
(0, fs_1.unlinkSync)((0, path_1.join)(path, file));
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
fs_1.rmdirSync(path);
|
|
21
|
+
(0, fs_1.rmdirSync)(path);
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Error thrown by the FileSystem which aims to be pretty
|
|
@@ -66,7 +66,7 @@ class FileSystem {
|
|
|
66
66
|
* @memberof FileSystem
|
|
67
67
|
*/
|
|
68
68
|
cd(path) {
|
|
69
|
-
this.currentDir = path_1.join(this.currentDir, path);
|
|
69
|
+
this.currentDir = (0, path_1.join)(this.currentDir, path);
|
|
70
70
|
return this;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
@@ -81,14 +81,14 @@ class FileSystem {
|
|
|
81
81
|
*/
|
|
82
82
|
cdProjectRootDir() {
|
|
83
83
|
// "/" on Unix, C:\ on Windows
|
|
84
|
-
const root = path_1.parse(process.cwd()).root;
|
|
84
|
+
const root = (0, path_1.parse)(process.cwd()).root;
|
|
85
85
|
while (!this.exists('package.json')) {
|
|
86
|
-
if (path_1.join(process.cwd(), this.parse('.')) === root) {
|
|
86
|
+
if ((0, path_1.join)(process.cwd(), this.parse('.')) === root) {
|
|
87
87
|
throw new ClientError('This project is not a FoalTS project. No package.json found.');
|
|
88
88
|
}
|
|
89
89
|
this.cd('..');
|
|
90
90
|
}
|
|
91
|
-
const content = fs_1.readFileSync(this.parse('package.json'), 'utf8');
|
|
91
|
+
const content = (0, fs_1.readFileSync)(this.parse('package.json'), 'utf8');
|
|
92
92
|
let pkg;
|
|
93
93
|
try {
|
|
94
94
|
pkg = JSON.parse(content);
|
|
@@ -109,7 +109,7 @@ class FileSystem {
|
|
|
109
109
|
* @memberof FileSystem
|
|
110
110
|
*/
|
|
111
111
|
exists(path) {
|
|
112
|
-
return fs_1.existsSync(this.parse(path));
|
|
112
|
+
return (0, fs_1.existsSync)(this.parse(path));
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Recursively ensures that a directory exists. If the directory structure does not
|
|
@@ -120,12 +120,12 @@ class FileSystem {
|
|
|
120
120
|
* @memberof FileSystem
|
|
121
121
|
*/
|
|
122
122
|
ensureDir(path) {
|
|
123
|
-
const dir = path_1.dirname(path);
|
|
123
|
+
const dir = (0, path_1.dirname)(path);
|
|
124
124
|
if (dir !== '.') {
|
|
125
125
|
this.ensureDir(dir);
|
|
126
126
|
}
|
|
127
|
-
if (!fs_1.existsSync(this.parse(path))) {
|
|
128
|
-
fs_1.mkdirSync(this.parse(path));
|
|
127
|
+
if (!(0, fs_1.existsSync)(this.parse(path))) {
|
|
128
|
+
(0, fs_1.mkdirSync)(this.parse(path));
|
|
129
129
|
}
|
|
130
130
|
return this;
|
|
131
131
|
}
|
|
@@ -152,9 +152,9 @@ class FileSystem {
|
|
|
152
152
|
* @memberof FileSystem
|
|
153
153
|
*/
|
|
154
154
|
ensureFile(path) {
|
|
155
|
-
if (!fs_1.existsSync(this.parse(path))) {
|
|
155
|
+
if (!(0, fs_1.existsSync)(this.parse(path))) {
|
|
156
156
|
this.logCreate(path);
|
|
157
|
-
fs_1.writeFileSync(this.parse(path), '', 'utf8');
|
|
157
|
+
(0, fs_1.writeFileSync)(this.parse(path), '', 'utf8');
|
|
158
158
|
}
|
|
159
159
|
return this;
|
|
160
160
|
}
|
|
@@ -167,12 +167,12 @@ class FileSystem {
|
|
|
167
167
|
* @memberof FileSystem
|
|
168
168
|
*/
|
|
169
169
|
copy(src, dest) {
|
|
170
|
-
const templatePath = path_1.join(__dirname, 'templates', src);
|
|
171
|
-
if (!fs_1.existsSync(templatePath)) {
|
|
170
|
+
const templatePath = (0, path_1.join)(__dirname, 'templates', src);
|
|
171
|
+
if (!(0, fs_1.existsSync)(templatePath)) {
|
|
172
172
|
throw new Error(`The template "${src}" does not exist.`);
|
|
173
173
|
}
|
|
174
174
|
this.logCreate(dest);
|
|
175
|
-
fs_1.copyFileSync(templatePath, this.parse(dest));
|
|
175
|
+
(0, fs_1.copyFileSync)(templatePath, this.parse(dest));
|
|
176
176
|
return this;
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
@@ -200,16 +200,16 @@ class FileSystem {
|
|
|
200
200
|
* @memberof FileSystem
|
|
201
201
|
*/
|
|
202
202
|
render(src, dest, locals) {
|
|
203
|
-
const templatePath = path_1.join(__dirname, 'templates', src);
|
|
204
|
-
if (!fs_1.existsSync(templatePath)) {
|
|
203
|
+
const templatePath = (0, path_1.join)(__dirname, 'templates', src);
|
|
204
|
+
if (!(0, fs_1.existsSync)(templatePath)) {
|
|
205
205
|
throw new Error(`The template "${src}" does not exist.`);
|
|
206
206
|
}
|
|
207
|
-
let content = fs_1.readFileSync(templatePath, 'utf8');
|
|
207
|
+
let content = (0, fs_1.readFileSync)(templatePath, 'utf8');
|
|
208
208
|
for (const key in locals) {
|
|
209
209
|
content = content.split(`/* ${key} */`).join(locals[key]);
|
|
210
210
|
}
|
|
211
211
|
this.logCreate(dest);
|
|
212
|
-
fs_1.writeFileSync(this.parse(dest), content, 'utf8');
|
|
212
|
+
(0, fs_1.writeFileSync)(this.parse(dest), content, 'utf8');
|
|
213
213
|
return this;
|
|
214
214
|
}
|
|
215
215
|
/**
|
|
@@ -237,12 +237,12 @@ class FileSystem {
|
|
|
237
237
|
* @memberof FileSystem
|
|
238
238
|
*/
|
|
239
239
|
modify(path, callback) {
|
|
240
|
-
if (!fs_1.existsSync(this.parse(path))) {
|
|
240
|
+
if (!(0, fs_1.existsSync)(this.parse(path))) {
|
|
241
241
|
throw new ClientError(`Impossible to modify "${path}": the file does not exist.`);
|
|
242
242
|
}
|
|
243
|
-
const content = fs_1.readFileSync(this.parse(path), 'utf8');
|
|
243
|
+
const content = (0, fs_1.readFileSync)(this.parse(path), 'utf8');
|
|
244
244
|
this.logUpdate(path);
|
|
245
|
-
fs_1.writeFileSync(this.parse(path), callback(content), 'utf8');
|
|
245
|
+
(0, fs_1.writeFileSync)(this.parse(path), callback(content), 'utf8');
|
|
246
246
|
return this;
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
@@ -386,7 +386,7 @@ class FileSystem {
|
|
|
386
386
|
projectHasDependency(name) {
|
|
387
387
|
const initialCurrentDir = this.currentDir;
|
|
388
388
|
this.cdProjectRootDir();
|
|
389
|
-
const pkg = JSON.parse(fs_1.readFileSync(this.parse('package.json'), 'utf8'));
|
|
389
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)(this.parse('package.json'), 'utf8'));
|
|
390
390
|
this.currentDir = initialCurrentDir;
|
|
391
391
|
return pkg.dependencies.hasOwnProperty(name);
|
|
392
392
|
}
|
|
@@ -398,7 +398,7 @@ class FileSystem {
|
|
|
398
398
|
getProjectDependencies() {
|
|
399
399
|
const initialCurrentDir = this.currentDir;
|
|
400
400
|
this.cdProjectRootDir();
|
|
401
|
-
const pkg = JSON.parse(fs_1.readFileSync(this.parse('package.json'), 'utf8'));
|
|
401
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)(this.parse('package.json'), 'utf8'));
|
|
402
402
|
this.currentDir = initialCurrentDir;
|
|
403
403
|
return Object.keys(pkg.dependencies)
|
|
404
404
|
.map(name => ({ name, version: pkg.dependencies[name] }));
|
|
@@ -411,7 +411,7 @@ class FileSystem {
|
|
|
411
411
|
getProjectDevDependencies() {
|
|
412
412
|
const initialCurrentDir = this.currentDir;
|
|
413
413
|
this.cdProjectRootDir();
|
|
414
|
-
const pkg = JSON.parse(fs_1.readFileSync(this.parse('package.json'), 'utf8'));
|
|
414
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)(this.parse('package.json'), 'utf8'));
|
|
415
415
|
this.currentDir = initialCurrentDir;
|
|
416
416
|
return Object.keys(pkg.devDependencies)
|
|
417
417
|
.map(name => ({ name, version: pkg.devDependencies[name] }));
|
|
@@ -426,8 +426,8 @@ class FileSystem {
|
|
|
426
426
|
*/
|
|
427
427
|
setUp() {
|
|
428
428
|
const [firstDir] = this.testDir.split('/');
|
|
429
|
-
fs_1.mkdirSync(firstDir);
|
|
430
|
-
fs_1.mkdirSync(this.testDir);
|
|
429
|
+
(0, fs_1.mkdirSync)(firstDir);
|
|
430
|
+
(0, fs_1.mkdirSync)(this.testDir);
|
|
431
431
|
this.currentDir = '';
|
|
432
432
|
}
|
|
433
433
|
/**
|
|
@@ -448,7 +448,7 @@ class FileSystem {
|
|
|
448
448
|
* @memberof FileSystem
|
|
449
449
|
*/
|
|
450
450
|
assertExists(path) {
|
|
451
|
-
if (!fs_1.existsSync(this.parse(path))) {
|
|
451
|
+
if (!(0, fs_1.existsSync)(this.parse(path))) {
|
|
452
452
|
throw new Error(`The file "${path}" does not exist.`);
|
|
453
453
|
}
|
|
454
454
|
return this;
|
|
@@ -461,7 +461,7 @@ class FileSystem {
|
|
|
461
461
|
* @memberof FileSystem
|
|
462
462
|
*/
|
|
463
463
|
assertNotExists(path) {
|
|
464
|
-
if (fs_1.existsSync(this.parse(path))) {
|
|
464
|
+
if ((0, fs_1.existsSync)(this.parse(path))) {
|
|
465
465
|
throw new Error(`The file "${path}" should not exist.`);
|
|
466
466
|
}
|
|
467
467
|
return this;
|
|
@@ -473,7 +473,7 @@ class FileSystem {
|
|
|
473
473
|
* @memberof FileSystem
|
|
474
474
|
*/
|
|
475
475
|
assertEmptyDir(path) {
|
|
476
|
-
if (fs_1.readdirSync(this.parse(path)).length > 0) {
|
|
476
|
+
if ((0, fs_1.readdirSync)(this.parse(path)).length > 0) {
|
|
477
477
|
throw new Error(`The directory "${path}" should be empty.`);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
@@ -487,15 +487,15 @@ class FileSystem {
|
|
|
487
487
|
* @memberof FileSystem
|
|
488
488
|
*/
|
|
489
489
|
assertEqual(actual, expected, { binary } = { binary: false }) {
|
|
490
|
-
const specPath = path_1.join(__dirname, 'specs', expected);
|
|
491
|
-
if (!fs_1.existsSync(specPath)) {
|
|
490
|
+
const specPath = (0, path_1.join)(__dirname, 'specs', expected);
|
|
491
|
+
if (!(0, fs_1.existsSync)(specPath)) {
|
|
492
492
|
throw new Error(`The spec file "${expected}" does not exist.`);
|
|
493
493
|
}
|
|
494
494
|
if (binary) {
|
|
495
|
-
assert_1.deepStrictEqual(fs_1.readFileSync(this.parse(actual)), fs_1.readFileSync(specPath));
|
|
495
|
+
(0, assert_1.deepStrictEqual)((0, fs_1.readFileSync)(this.parse(actual)), (0, fs_1.readFileSync)(specPath));
|
|
496
496
|
}
|
|
497
497
|
else {
|
|
498
|
-
assert_1.strictEqual(fs_1.readFileSync(this.parse(actual), 'utf8'), fs_1.readFileSync(specPath, 'utf8'));
|
|
498
|
+
(0, assert_1.strictEqual)((0, fs_1.readFileSync)(this.parse(actual), 'utf8'), (0, fs_1.readFileSync)(specPath, 'utf8'));
|
|
499
499
|
}
|
|
500
500
|
return this;
|
|
501
501
|
}
|
|
@@ -508,11 +508,11 @@ class FileSystem {
|
|
|
508
508
|
* @memberof FileSystem
|
|
509
509
|
*/
|
|
510
510
|
copyFixture(src, dest) {
|
|
511
|
-
const fixturePath = path_1.join(__dirname, 'fixtures', src);
|
|
512
|
-
if (!fs_1.existsSync(fixturePath)) {
|
|
511
|
+
const fixturePath = (0, path_1.join)(__dirname, 'fixtures', src);
|
|
512
|
+
if (!(0, fs_1.existsSync)(fixturePath)) {
|
|
513
513
|
throw new Error(`The fixture file "${src}" does not exist.`);
|
|
514
514
|
}
|
|
515
|
-
fs_1.copyFileSync(fixturePath, this.parse(dest));
|
|
515
|
+
(0, fs_1.copyFileSync)(fixturePath, this.parse(dest));
|
|
516
516
|
return this;
|
|
517
517
|
}
|
|
518
518
|
/**
|
|
@@ -522,29 +522,29 @@ class FileSystem {
|
|
|
522
522
|
* @memberof FileSystem
|
|
523
523
|
*/
|
|
524
524
|
rmfile(path) {
|
|
525
|
-
fs_1.unlinkSync(this.parse(path));
|
|
525
|
+
(0, fs_1.unlinkSync)(this.parse(path));
|
|
526
526
|
}
|
|
527
527
|
isTestingEnvironment() {
|
|
528
528
|
return process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST === 'true';
|
|
529
529
|
}
|
|
530
530
|
parse(path) {
|
|
531
531
|
if (this.isTestingEnvironment()) {
|
|
532
|
-
return path_1.join(this.testDir, this.currentDir, path);
|
|
532
|
+
return (0, path_1.join)(this.testDir, this.currentDir, path);
|
|
533
533
|
}
|
|
534
|
-
return path_1.join(this.currentDir, path);
|
|
534
|
+
return (0, path_1.join)(this.currentDir, path);
|
|
535
535
|
}
|
|
536
536
|
logCreate(path) {
|
|
537
|
-
path = path_1.join(this.currentDir, path);
|
|
537
|
+
path = (0, path_1.join)(this.currentDir, path);
|
|
538
538
|
// && !this.options.noLogs
|
|
539
539
|
if (!this.isTestingEnvironment() && this.logs) {
|
|
540
|
-
console.log(`${safe_1.green('CREATE')} ${path}`);
|
|
540
|
+
console.log(`${(0, safe_1.green)('CREATE')} ${path}`);
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
logUpdate(path) {
|
|
544
544
|
// && !this.options.noLogs
|
|
545
|
-
path = path_1.join(this.currentDir, path);
|
|
545
|
+
path = (0, path_1.join)(this.currentDir, path);
|
|
546
546
|
if (!this.isTestingEnvironment() && this.logs) {
|
|
547
|
-
console.log(`${safe_1.cyan('UPDATE')} ${path}`);
|
|
547
|
+
console.log(`${(0, safe_1.cyan)('UPDATE')} ${path}`);
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
}
|
|
@@ -8,19 +8,19 @@ function connectAngular(path) {
|
|
|
8
8
|
const fs = new file_system_1.FileSystem();
|
|
9
9
|
if (!fs.exists(path)) {
|
|
10
10
|
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
11
|
-
console.log(safe_1.red(` The directory ${path} does not exist.`));
|
|
11
|
+
console.log((0, safe_1.red)(` The directory ${path} does not exist.`));
|
|
12
12
|
}
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
if (!fs.exists(path_1.join(path, 'angular.json'))) {
|
|
15
|
+
if (!fs.exists((0, path_1.join)(path, 'angular.json'))) {
|
|
16
16
|
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
17
|
-
console.log(safe_1.red(` The directory ${path} is not an Angular project (missing angular.json).`));
|
|
17
|
+
console.log((0, safe_1.red)(` The directory ${path} is not an Angular project (missing angular.json).`));
|
|
18
18
|
}
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
if (!fs.exists(path_1.join(path, 'package.json'))) {
|
|
21
|
+
if (!fs.exists((0, path_1.join)(path, 'package.json'))) {
|
|
22
22
|
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
23
|
-
console.log(safe_1.red(` The directory ${path} is not an Angular project (missing package.json).`));
|
|
23
|
+
console.log((0, safe_1.red)(` The directory ${path} is not an Angular project (missing package.json).`));
|
|
24
24
|
}
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
@@ -33,19 +33,18 @@ function connectAngular(path) {
|
|
|
33
33
|
return JSON.stringify(pkg, null, 2);
|
|
34
34
|
})
|
|
35
35
|
.modify('angular.json', content => {
|
|
36
|
-
var _a, _b, _c, _d, _e;
|
|
37
36
|
const config = JSON.parse(content);
|
|
38
37
|
// Proxy configuration
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
config.projects[config.defaultProject].architect ||= {};
|
|
39
|
+
config.projects[config.defaultProject].architect.serve ||= {};
|
|
40
|
+
config.projects[config.defaultProject].architect.serve.options ||= {};
|
|
42
41
|
config.projects[config.defaultProject].architect.serve.options.proxyConfig = 'src/proxy.conf.json';
|
|
43
42
|
// Output build directory
|
|
44
|
-
const outputPath = path_1.join(path_1.relative(path, process.cwd()), 'public')
|
|
43
|
+
const outputPath = (0, path_1.join)((0, path_1.relative)(path, process.cwd()), 'public')
|
|
45
44
|
// Make projects generated on Windows build on Unix.
|
|
46
45
|
.replace(/\\/g, '/');
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
config.projects[config.defaultProject].architect.build ||= {};
|
|
47
|
+
config.projects[config.defaultProject].architect.build.options ||= {};
|
|
49
48
|
config.projects[config.defaultProject].architect.build.options.outputPath = outputPath;
|
|
50
49
|
return JSON.stringify(config, null, 2);
|
|
51
50
|
});
|
|
@@ -11,10 +11,10 @@ const file_system_1 = require("../../file-system");
|
|
|
11
11
|
const utils_1 = require("../../utils");
|
|
12
12
|
function isYarnInstalled() {
|
|
13
13
|
try {
|
|
14
|
-
child_process_1.execSync('yarn --version', { stdio: 'ignore' });
|
|
14
|
+
(0, child_process_1.execSync)('yarn --version', { stdio: 'ignore' });
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
|
-
catch
|
|
17
|
+
catch {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -32,10 +32,10 @@ function log(msg = '', spinner = false) {
|
|
|
32
32
|
console.log(msg);
|
|
33
33
|
}
|
|
34
34
|
function logCommand(msg) {
|
|
35
|
-
log(` $ ${safe_1.cyan(msg)}`);
|
|
35
|
+
log(` $ ${(0, safe_1.cyan)(msg)}`);
|
|
36
36
|
}
|
|
37
37
|
async function createApp({ name, autoInstall, initRepo, mongodb = false, yaml = false }) {
|
|
38
|
-
const names = utils_1.getNames(name);
|
|
38
|
+
const names = (0, utils_1.getNames)(name);
|
|
39
39
|
log();
|
|
40
40
|
log(' ------------------------------------------------- ');
|
|
41
41
|
log('| |');
|
|
@@ -46,7 +46,7 @@ async function createApp({ name, autoInstall, initRepo, mongodb = false, yaml =
|
|
|
46
46
|
const fs = new file_system_1.FileSystem();
|
|
47
47
|
if (fs.exists(names.kebabName)) {
|
|
48
48
|
log();
|
|
49
|
-
log(safe_1.red(' Error: ') + `The target directory "${names.kebabName}" already exists.`);
|
|
49
|
+
log((0, safe_1.red)(' Error: ') + `The target directory "${names.kebabName}" already exists.`);
|
|
50
50
|
log('Please remove it before proceeding.');
|
|
51
51
|
log();
|
|
52
52
|
return;
|
|
@@ -59,7 +59,6 @@ async function createApp({ name, autoInstall, initRepo, mongodb = false, yaml =
|
|
|
59
59
|
fs
|
|
60
60
|
.hideLogs()
|
|
61
61
|
.copy('app/gitignore', '.gitignore')
|
|
62
|
-
.copy('app/ormconfig.js', 'ormconfig.js')
|
|
63
62
|
.renderOnlyIf(!mongodb && !yaml, 'app/package.json', 'package.json', locals)
|
|
64
63
|
.renderOnlyIf(!mongodb && yaml, 'app/package.yaml.json', 'package.json', locals)
|
|
65
64
|
.renderOnlyIf(mongodb && !yaml, 'app/package.mongodb.json', 'package.json', locals)
|
|
@@ -98,6 +97,7 @@ async function createApp({ name, autoInstall, initRepo, mongodb = false, yaml =
|
|
|
98
97
|
// Src
|
|
99
98
|
.ensureDir('src')
|
|
100
99
|
.cd('src')
|
|
100
|
+
.copy('app/src/db.ts', 'db.ts')
|
|
101
101
|
.copy('app/src/e2e.ts', 'e2e.ts')
|
|
102
102
|
.copy('app/src/index.ts', 'index.ts')
|
|
103
103
|
.copy('app/src/test.ts', 'test.ts')
|
|
@@ -138,8 +138,7 @@ async function createApp({ name, autoInstall, initRepo, mongodb = false, yaml =
|
|
|
138
138
|
// Scripts
|
|
139
139
|
.ensureDir('scripts')
|
|
140
140
|
.cd('scripts')
|
|
141
|
-
.
|
|
142
|
-
.copyOnlyIf(mongodb, 'app/src/scripts/create-user.mongodb.ts', 'create-user.ts');
|
|
141
|
+
.copy('app/src/scripts/create-user.ts', 'create-user.ts');
|
|
143
142
|
if (autoInstall) {
|
|
144
143
|
const packageManager = isYarnInstalled() ? 'yarn' : 'npm';
|
|
145
144
|
log();
|
|
@@ -152,7 +151,7 @@ async function createApp({ name, autoInstall, initRepo, mongodb = false, yaml =
|
|
|
152
151
|
stdio: 'ignore',
|
|
153
152
|
};
|
|
154
153
|
const success = await new Promise(resolve => {
|
|
155
|
-
child_process_1.spawn(packageManager, args, options)
|
|
154
|
+
(0, child_process_1.spawn)(packageManager, args, options)
|
|
156
155
|
.on('close', (code) => resolve(code === 0));
|
|
157
156
|
});
|
|
158
157
|
if (spinner) {
|
|
@@ -161,7 +160,7 @@ async function createApp({ name, autoInstall, initRepo, mongodb = false, yaml =
|
|
|
161
160
|
if (!success) {
|
|
162
161
|
log(` ❗ Installing dependencies (${packageManager})...`);
|
|
163
162
|
log();
|
|
164
|
-
log(safe_1.red(' Error: ') + 'A problem occurred during the installation of');
|
|
163
|
+
log((0, safe_1.red)(' Error: ') + 'A problem occurred during the installation of');
|
|
165
164
|
log('the dependencies. Try installing them manually by running');
|
|
166
165
|
log('the following commands:');
|
|
167
166
|
log();
|
|
@@ -177,7 +176,7 @@ async function createApp({ name, autoInstall, initRepo, mongodb = false, yaml =
|
|
|
177
176
|
if (initRepo) {
|
|
178
177
|
log();
|
|
179
178
|
log(' 📔 Initializing git repository...');
|
|
180
|
-
await utils_1.initGitRepo(names.kebabName);
|
|
179
|
+
await (0, utils_1.initGitRepo)(names.kebabName);
|
|
181
180
|
}
|
|
182
181
|
log();
|
|
183
182
|
log('✨ Project successfully created.');
|
|
@@ -187,7 +186,7 @@ async function createApp({ name, autoInstall, initRepo, mongodb = false, yaml =
|
|
|
187
186
|
if (!autoInstall) {
|
|
188
187
|
logCommand('npm install');
|
|
189
188
|
}
|
|
190
|
-
logCommand('npm run
|
|
189
|
+
logCommand('npm run dev');
|
|
191
190
|
log();
|
|
192
191
|
}
|
|
193
192
|
exports.createApp = createApp;
|
|
@@ -15,9 +15,9 @@ function createController({ name, register }) {
|
|
|
15
15
|
else if (fs.exists('controllers')) {
|
|
16
16
|
root = 'controllers';
|
|
17
17
|
}
|
|
18
|
-
const names = utils_1.getNames(path_1.basename(name));
|
|
19
|
-
const subdir = path_1.dirname(name);
|
|
20
|
-
const parentControllerPath = `${subdir === '.' ? 'app' : path_1.basename(subdir)}.controller.ts`;
|
|
18
|
+
const names = (0, utils_1.getNames)((0, path_1.basename)(name));
|
|
19
|
+
const subdir = (0, path_1.dirname)(name);
|
|
20
|
+
const parentControllerPath = `${subdir === '.' ? 'app' : (0, path_1.basename)(subdir)}.controller.ts`;
|
|
21
21
|
const fileName = `${names.kebabName}.controller.ts`;
|
|
22
22
|
const specFileName = `${names.kebabName}.controller.spec.ts`;
|
|
23
23
|
const className = `${names.upperFirstCamelName}Controller`;
|
|
@@ -33,7 +33,7 @@ function createController({ name, register }) {
|
|
|
33
33
|
fs
|
|
34
34
|
.cd('..')
|
|
35
35
|
.addOrExtendNamedImportIn(parentControllerPath, 'controller', '@foal/core', { logs: false })
|
|
36
|
-
.addOrExtendNamedImportIn(parentControllerPath, className, `./${subdir === '.' ? 'controllers' : path_1.basename(subdir)}`, { logs: false })
|
|
36
|
+
.addOrExtendNamedImportIn(parentControllerPath, className, `./${subdir === '.' ? 'controllers' : (0, path_1.basename)(subdir)}`, { logs: false })
|
|
37
37
|
.addOrExtendClassArrayPropertyIn(parentControllerPath, 'subControllers', `controller('/${names.kebabName}', ${className})`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -14,8 +14,8 @@ function createEntity({ name }) {
|
|
|
14
14
|
else if (fs.exists('entities')) {
|
|
15
15
|
root = 'entities';
|
|
16
16
|
}
|
|
17
|
-
const names = utils_1.getNames(path_1.basename(name));
|
|
18
|
-
const subdir = path_1.dirname(name);
|
|
17
|
+
const names = (0, utils_1.getNames)((0, path_1.basename)(name));
|
|
18
|
+
const subdir = (0, path_1.dirname)(name);
|
|
19
19
|
const isMongoDBProject = fs.projectHasDependency('mongodb');
|
|
20
20
|
fs
|
|
21
21
|
.cd(root)
|
|
@@ -14,8 +14,8 @@ function createHook({ name }) {
|
|
|
14
14
|
else if (fs.exists('hooks')) {
|
|
15
15
|
root = 'hooks';
|
|
16
16
|
}
|
|
17
|
-
const names = utils_1.getNames(path_1.basename(name));
|
|
18
|
-
const subdir = path_1.dirname(name);
|
|
17
|
+
const names = (0, utils_1.getNames)((0, path_1.basename)(name));
|
|
18
|
+
const subdir = (0, path_1.dirname)(name);
|
|
19
19
|
fs
|
|
20
20
|
.cd(root)
|
|
21
21
|
.ensureDir(subdir)
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -19,5 +23,4 @@ __exportStar(require("./react"), exports);
|
|
|
19
23
|
__exportStar(require("./rest-api"), exports);
|
|
20
24
|
__exportStar(require("./script"), exports);
|
|
21
25
|
__exportStar(require("./service"), exports);
|
|
22
|
-
__exportStar(require("./vscode-config"), exports);
|
|
23
26
|
__exportStar(require("./vue"), exports);
|
|
@@ -8,13 +8,13 @@ function connectReact(path) {
|
|
|
8
8
|
const fs = new file_system_1.FileSystem();
|
|
9
9
|
if (!fs.exists(path)) {
|
|
10
10
|
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
11
|
-
console.log(safe_1.red(` The directory ${path} does not exist.`));
|
|
11
|
+
console.log((0, safe_1.red)(` The directory ${path} does not exist.`));
|
|
12
12
|
}
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
if (!fs.exists(path_1.join(path, 'package.json'))) {
|
|
15
|
+
if (!fs.exists((0, path_1.join)(path, 'package.json'))) {
|
|
16
16
|
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
17
|
-
console.log(safe_1.red(` The directory ${path} is not a React project (missing package.json).`));
|
|
17
|
+
console.log((0, safe_1.red)(` The directory ${path} is not a React project (missing package.json).`));
|
|
18
18
|
}
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
@@ -21,9 +21,13 @@ function createRestApi({ name, register, auth }) {
|
|
|
21
21
|
throw new file_system_1.ClientError('Impossible to generate a REST API endpoint. '
|
|
22
22
|
+ 'The directories controllers/ and entities/ (or src/app/controllers and src/app/entities) were not found.');
|
|
23
23
|
}
|
|
24
|
-
const locals =
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const locals = {
|
|
25
|
+
...(0, utils_1.getNames)((0, path_1.basename)(name)),
|
|
26
|
+
entitiesPath: `${name.split('/').map(() => '../').join('')}entities`,
|
|
27
|
+
createDataSourcePath: `${name.split('/').map(() => '../').join('')}../db`,
|
|
28
|
+
};
|
|
29
|
+
const subdir = (0, path_1.dirname)(name);
|
|
30
|
+
const parentControllerPath = `${subdir === '.' ? 'app' : (0, path_1.basename)(subdir)}.controller.ts`;
|
|
27
31
|
const entityFileName = `${locals.kebabName}.entity.ts`;
|
|
28
32
|
fs
|
|
29
33
|
.cd('entities')
|
|
@@ -49,11 +53,11 @@ function createRestApi({ name, register, auth }) {
|
|
|
49
53
|
if (register) {
|
|
50
54
|
fs
|
|
51
55
|
.addOrExtendNamedImportIn(parentControllerPath, 'controller', '@foal/core', { logs: false })
|
|
52
|
-
.addOrExtendNamedImportIn(parentControllerPath, controllerClassName, `./${subdir === '.' ? 'controllers' : path_1.basename(subdir)}`, { logs: false })
|
|
56
|
+
.addOrExtendNamedImportIn(parentControllerPath, controllerClassName, `./${subdir === '.' ? 'controllers' : (0, path_1.basename)(subdir)}`, { logs: false })
|
|
53
57
|
.addOrExtendClassArrayPropertyIn(parentControllerPath, 'subControllers', `controller('/${locals.kebabName}s', ${controllerClassName})`);
|
|
54
58
|
}
|
|
55
59
|
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
56
|
-
console.log(`\n${safe_1.underline('Next steps:')} Complete ${locals.upperFirstCamelName} (${locals.kebabName}.entity)`
|
|
60
|
+
console.log(`\n${(0, safe_1.underline)('Next steps:')} Complete ${locals.upperFirstCamelName} (${locals.kebabName}.entity)`
|
|
57
61
|
+ ` and ${locals.camelName}Schema (${locals.kebabName}.controller).`);
|
|
58
62
|
}
|
|
59
63
|
}
|
|
@@ -5,7 +5,7 @@ exports.createScript = void 0;
|
|
|
5
5
|
const file_system_1 = require("../../file-system");
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
function createScript({ name }) {
|
|
8
|
-
const names = utils_1.getNames(name);
|
|
8
|
+
const names = (0, utils_1.getNames)(name);
|
|
9
9
|
const fs = new file_system_1.FileSystem();
|
|
10
10
|
fs
|
|
11
11
|
// TODO: test this line
|
|
@@ -14,8 +14,8 @@ function createService({ name }) {
|
|
|
14
14
|
else if (fs.exists('services')) {
|
|
15
15
|
root = 'services';
|
|
16
16
|
}
|
|
17
|
-
const names = utils_1.getNames(path_1.basename(name));
|
|
18
|
-
const subdir = path_1.dirname(name);
|
|
17
|
+
const names = (0, utils_1.getNames)((0, path_1.basename)(name));
|
|
18
|
+
const subdir = (0, path_1.dirname)(name);
|
|
19
19
|
fs
|
|
20
20
|
.cd(root)
|
|
21
21
|
.ensureDir(subdir)
|
|
@@ -8,13 +8,13 @@ function connectVue(path) {
|
|
|
8
8
|
const fs = new file_system_1.FileSystem();
|
|
9
9
|
if (!fs.exists(path)) {
|
|
10
10
|
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
11
|
-
console.log(safe_1.red(` The directory ${path} does not exist.`));
|
|
11
|
+
console.log((0, safe_1.red)(` The directory ${path} does not exist.`));
|
|
12
12
|
}
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
if (!fs.exists(path_1.join(path, 'package.json'))) {
|
|
15
|
+
if (!fs.exists((0, path_1.join)(path, 'package.json'))) {
|
|
16
16
|
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
17
|
-
console.log(safe_1.red(` The directory ${path} is not a Vue project (missing package.json).`));
|
|
17
|
+
console.log((0, safe_1.red)(` The directory ${path} is not a Vue project (missing package.json).`));
|
|
18
18
|
}
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
@@ -28,7 +28,7 @@ function connectVue(path) {
|
|
|
28
28
|
pkg.vue.devServer.proxy = pkg.vue.devServer.proxy || {};
|
|
29
29
|
pkg.vue.devServer.proxy['^/api'] = { target: 'http://localhost:3001' };
|
|
30
30
|
// Output build directory
|
|
31
|
-
const outputPath = path_1.join(path_1.relative(path, process.cwd()), 'public')
|
|
31
|
+
const outputPath = (0, path_1.join)((0, path_1.relative)(path, process.cwd()), 'public')
|
|
32
32
|
// Make projects generated on Windows build on Unix.
|
|
33
33
|
.replace(/\\/g, '/');
|
|
34
34
|
pkg.vue.outputDir = outputPath;
|
package/lib/generate/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|