@foal/cli 2.3.0 → 2.7.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/generate/generators/angular/connect-angular.js +6 -0
- package/lib/generate/generators/entity/create-entity.js +5 -1
- package/lib/generate/generators/hook/create-hook.js +5 -1
- package/lib/generate/templates/app/package.json +1 -1
- package/lib/generate/templates/app/package.mongodb.json +2 -2
- package/lib/generate/templates/app/package.mongodb.yaml.json +2 -2
- package/lib/generate/templates/app/package.yaml.json +2 -2
- package/lib/generate/templates/app/src/scripts/create-user.ts +9 -38
- package/package.json +2 -2
|
@@ -33,13 +33,19 @@ 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;
|
|
36
37
|
const config = JSON.parse(content);
|
|
37
38
|
// Proxy configuration
|
|
39
|
+
(_a = config.projects[config.defaultProject]).architect || (_a.architect = {});
|
|
40
|
+
(_b = config.projects[config.defaultProject].architect).serve || (_b.serve = {});
|
|
41
|
+
(_c = config.projects[config.defaultProject].architect.serve).options || (_c.options = {});
|
|
38
42
|
config.projects[config.defaultProject].architect.serve.options.proxyConfig = 'src/proxy.conf.json';
|
|
39
43
|
// Output build directory
|
|
40
44
|
const outputPath = path_1.join(path_1.relative(path, process.cwd()), 'public')
|
|
41
45
|
// Make projects generated on Windows build on Unix.
|
|
42
46
|
.replace(/\\/g, '/');
|
|
47
|
+
(_d = config.projects[config.defaultProject].architect).build || (_d.build = {});
|
|
48
|
+
(_e = config.projects[config.defaultProject].architect.build).options || (_e.options = {});
|
|
43
49
|
config.projects[config.defaultProject].architect.build.options.outputPath = outputPath;
|
|
44
50
|
return JSON.stringify(config, null, 2);
|
|
45
51
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEntity = void 0;
|
|
4
4
|
// FoalTS
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const file_system_1 = require("../../file-system");
|
|
6
7
|
const utils_1 = require("../../utils");
|
|
7
8
|
function createEntity({ name }) {
|
|
@@ -13,10 +14,13 @@ function createEntity({ name }) {
|
|
|
13
14
|
else if (fs.exists('entities')) {
|
|
14
15
|
root = 'entities';
|
|
15
16
|
}
|
|
16
|
-
const names = utils_1.getNames(name);
|
|
17
|
+
const names = utils_1.getNames(path_1.basename(name));
|
|
18
|
+
const subdir = path_1.dirname(name);
|
|
17
19
|
const isMongoDBProject = fs.projectHasDependency('mongodb');
|
|
18
20
|
fs
|
|
19
21
|
.cd(root)
|
|
22
|
+
.ensureDir(subdir)
|
|
23
|
+
.cd(subdir)
|
|
20
24
|
.renderOnlyIf(!isMongoDBProject, 'entity/entity.ts', `${names.kebabName}.entity.ts`, names)
|
|
21
25
|
.renderOnlyIf(isMongoDBProject, 'entity/entity.mongodb.ts', `${names.kebabName}.entity.ts`, names)
|
|
22
26
|
.ensureFile('index.ts')
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createHook = void 0;
|
|
4
4
|
// FoalTS
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const file_system_1 = require("../../file-system");
|
|
6
7
|
const utils_1 = require("../../utils");
|
|
7
8
|
function createHook({ name }) {
|
|
@@ -13,9 +14,12 @@ function createHook({ name }) {
|
|
|
13
14
|
else if (fs.exists('hooks')) {
|
|
14
15
|
root = 'hooks';
|
|
15
16
|
}
|
|
16
|
-
const names = utils_1.getNames(name);
|
|
17
|
+
const names = utils_1.getNames(path_1.basename(name));
|
|
18
|
+
const subdir = path_1.dirname(name);
|
|
17
19
|
fs
|
|
18
20
|
.cd(root)
|
|
21
|
+
.ensureDir(subdir)
|
|
22
|
+
.cd(subdir)
|
|
19
23
|
.render('hook/hook.ts', `${names.kebabName}.hook.ts`, names)
|
|
20
24
|
.ensureFile('index.ts')
|
|
21
25
|
.addNamedExportIn('index.ts', names.upperFirstCamelName, `./${names.kebabName}.hook`);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "foal rmdir build && tsc -p tsconfig.app.json",
|
|
9
9
|
"start": "node ./build/index.js",
|
|
10
|
-
"develop": "npm run build && concurrently \"tsc -p tsconfig.app.json -w\" \"supervisor -w ./build --no-restart-on error ./build/index.js\"",
|
|
10
|
+
"develop": "npm run build && concurrently \"tsc -p tsconfig.app.json -w\" \"supervisor -w ./build,./config -e js,json,yml --no-restart-on error ./build/index.js\"",
|
|
11
11
|
|
|
12
12
|
"build:test": "foal rmdir build && tsc -p tsconfig.test.json",
|
|
13
13
|
"start:test": "mocha --file ./build/test.js \"./build/**/*.spec.js\"",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "foal rmdir build && tsc -p tsconfig.app.json",
|
|
9
9
|
"start": "node ./build/index.js",
|
|
10
|
-
"develop": "npm run build && concurrently \"tsc -p tsconfig.app.json -w\" \"supervisor -w ./build --no-restart-on error ./build/index.js\"",
|
|
10
|
+
"develop": "npm run build && concurrently \"tsc -p tsconfig.app.json -w\" \"supervisor -w ./build,./config -e js,json,yml --no-restart-on error ./build/index.js\"",
|
|
11
11
|
|
|
12
12
|
"build:test": "foal rmdir build && tsc -p tsconfig.test.json",
|
|
13
13
|
"start:test": "mocha --file ./build/test.js \"./build/**/*.spec.js\"",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"lint:fix": "eslint --ext ts --fix src"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
24
|
+
"node": ">=10"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@foal/core": "^2.0.0",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "foal rmdir build && tsc -p tsconfig.app.json",
|
|
9
9
|
"start": "node ./build/index.js",
|
|
10
|
-
"develop": "npm run build && concurrently \"tsc -p tsconfig.app.json -w\" \"supervisor -w ./build --no-restart-on error ./build/index.js\"",
|
|
10
|
+
"develop": "npm run build && concurrently \"tsc -p tsconfig.app.json -w\" \"supervisor -w ./build,./config -e js,json,yml --no-restart-on error ./build/index.js\"",
|
|
11
11
|
|
|
12
12
|
"build:test": "foal rmdir build && tsc -p tsconfig.test.json",
|
|
13
13
|
"start:test": "mocha --file ./build/test.js \"./build/**/*.spec.js\"",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"lint:fix": "eslint --ext ts --fix src"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": ">=
|
|
24
|
+
"node": ">=10"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@foal/core": "^2.0.0",
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "foal rmdir build && tsc -p tsconfig.app.json",
|
|
9
9
|
"start": "node ./build/index.js",
|
|
10
|
-
"develop": "npm run build && concurrently \"tsc -p tsconfig.app.json -w\" \"supervisor -w ./build --no-restart-on error ./build/index.js\"",
|
|
10
|
+
"develop": "npm run build && concurrently \"tsc -p tsconfig.app.json -w\" \"supervisor -w ./build,./config -e js,json,yml --no-restart-on error ./build/index.js\"",
|
|
11
11
|
|
|
12
12
|
"build:test": "foal rmdir build && tsc -p tsconfig.test.json",
|
|
13
13
|
"start:test": "mocha --file ./build/test.js \"./build/**/*.spec.js\"",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"revertmigration": "npx typeorm migration:revert"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
28
|
+
"node": ">=10"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@foal/core": "^2.0.0",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// 3p
|
|
2
|
-
// import {
|
|
3
|
-
|
|
4
|
-
import { createConnection, getConnection, getManager } from 'typeorm';
|
|
2
|
+
// import { hashPassword } from '@foal/core';
|
|
3
|
+
import { createConnection } from 'typeorm';
|
|
5
4
|
|
|
6
5
|
// App
|
|
7
6
|
import { User } from '../app/entities';
|
|
@@ -10,52 +9,24 @@ export const schema = {
|
|
|
10
9
|
additionalProperties: false,
|
|
11
10
|
properties: {
|
|
12
11
|
// email: { type: 'string', format: 'email' },
|
|
13
|
-
// groups: { type: 'array', items: { type: 'string' }, uniqueItems: true, default: [] },
|
|
14
12
|
// password: { type: 'string' },
|
|
15
|
-
// userPermissions: { type: 'array', items: { type: 'string' }, uniqueItems: true, default: [] },
|
|
16
13
|
},
|
|
17
14
|
required: [ /* 'email', 'password' */ ],
|
|
18
15
|
type: 'object',
|
|
19
16
|
};
|
|
20
17
|
|
|
21
18
|
export async function main(/*args*/) {
|
|
22
|
-
const
|
|
23
|
-
// user.userPermissions = [];
|
|
24
|
-
// user.groups = [];
|
|
25
|
-
// user.email = args.email;
|
|
26
|
-
// if (await isCommon(args.password)) {
|
|
27
|
-
// console.log('This password is too common. Please choose another one.');
|
|
28
|
-
// return;
|
|
29
|
-
// }
|
|
30
|
-
// await user.setPassword(args.password);
|
|
31
|
-
|
|
32
|
-
await createConnection();
|
|
33
|
-
|
|
34
|
-
// for (const codeName of args.userPermissions as string[]) {
|
|
35
|
-
// const permission = await Permission.findOne({ codeName });
|
|
36
|
-
// if (!permission) {
|
|
37
|
-
// console.log(`No permission with the code name "${codeName}" was found.`);
|
|
38
|
-
// return;
|
|
39
|
-
// }
|
|
40
|
-
// user.userPermissions.push(permission);
|
|
41
|
-
// }
|
|
42
|
-
|
|
43
|
-
// for (const codeName of args.groups as string[]) {
|
|
44
|
-
// const group = await Group.findOne({ codeName });
|
|
45
|
-
// if (!group) {
|
|
46
|
-
// console.log(`No group with the code name "${codeName}" was found.`);
|
|
47
|
-
// return;
|
|
48
|
-
// }
|
|
49
|
-
// user.groups.push(group);
|
|
50
|
-
// }
|
|
19
|
+
const connection = await createConnection();
|
|
51
20
|
|
|
52
21
|
try {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
22
|
+
const user = new User();
|
|
23
|
+
// user.email = args.email;
|
|
24
|
+
// user.password = await hashPassword(args.password);
|
|
25
|
+
|
|
26
|
+
console.log(await user.save());
|
|
56
27
|
} catch (error) {
|
|
57
28
|
console.log(error.message);
|
|
58
29
|
} finally {
|
|
59
|
-
await
|
|
30
|
+
await connection.close();
|
|
60
31
|
}
|
|
61
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foal/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "CLI tool for FoalTS",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"ts-node": "~9.0.0",
|
|
72
72
|
"typescript": "~4.0.2"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "f29806e349427d412606a2086ae474f2b65df3ac"
|
|
75
75
|
}
|