@foal/cli 5.1.3 → 5.2.1
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/cli.d.ts +6 -0
- package/lib/cli.js +208 -0
- package/lib/commands/connectors/connect-angular/connect-angular-command.service.d.ts +15 -0
- package/lib/commands/connectors/connect-angular/connect-angular-command.service.js +66 -0
- package/lib/commands/connectors/connect-angular/index.d.ts +1 -0
- package/lib/commands/connectors/connect-angular/index.js +5 -0
- package/lib/commands/connectors/connect-react/connect-react-command.service.d.ts +15 -0
- package/lib/commands/connectors/connect-react/connect-react-command.service.js +47 -0
- package/lib/commands/connectors/connect-react/index.d.ts +1 -0
- package/lib/commands/connectors/connect-react/index.js +5 -0
- package/lib/commands/connectors/connect-vue/connect-vue-command.service.d.ts +15 -0
- package/lib/commands/connectors/connect-vue/connect-vue-command.service.js +51 -0
- package/lib/commands/connectors/connect-vue/index.d.ts +1 -0
- package/lib/commands/connectors/connect-vue/index.js +5 -0
- package/lib/commands/connectors/index.d.ts +3 -0
- package/lib/commands/connectors/index.js +9 -0
- package/lib/commands/create-secret/create-secret-command.service.d.ts +7 -0
- package/lib/commands/create-secret/create-secret-command.service.js +16 -0
- package/lib/commands/create-secret/index.d.ts +1 -0
- package/lib/commands/create-secret/index.js +5 -0
- package/lib/commands/generators/create-app/create-app-command.service.d.ts +25 -0
- package/lib/commands/generators/create-app/create-app-command.service.js +151 -0
- package/lib/commands/generators/create-app/index.d.ts +1 -0
- package/lib/commands/generators/create-app/index.js +5 -0
- package/lib/commands/generators/create-controller/create-controller-command.service.d.ts +19 -0
- package/lib/commands/generators/create-controller/create-controller-command.service.js +53 -0
- package/lib/commands/generators/create-controller/index.d.ts +1 -0
- package/lib/commands/generators/create-controller/index.js +5 -0
- package/lib/commands/generators/create-entity/create-entity-command.service.d.ts +17 -0
- package/lib/commands/generators/create-entity/create-entity-command.service.js +42 -0
- package/lib/commands/generators/create-entity/index.d.ts +1 -0
- package/lib/commands/generators/create-entity/index.js +5 -0
- package/lib/commands/generators/create-hook/create-hook-command.service.d.ts +17 -0
- package/lib/commands/generators/create-hook/create-hook-command.service.js +40 -0
- package/lib/commands/generators/create-hook/index.d.ts +1 -0
- package/lib/commands/generators/create-hook/index.js +5 -0
- package/lib/commands/generators/create-rest-api/create-rest-api-command.service.d.ts +21 -0
- package/lib/commands/generators/create-rest-api/create-rest-api-command.service.js +80 -0
- package/lib/commands/generators/create-rest-api/index.d.ts +1 -0
- package/lib/commands/generators/create-rest-api/index.js +5 -0
- package/lib/commands/generators/create-script/create-script-command.service.d.ts +17 -0
- package/lib/commands/generators/create-script/create-script-command.service.js +28 -0
- package/lib/commands/generators/create-script/index.d.ts +1 -0
- package/lib/commands/generators/create-script/index.js +5 -0
- package/lib/commands/generators/create-service/create-service-command.service.d.ts +17 -0
- package/lib/commands/generators/create-service/create-service-command.service.js +40 -0
- package/lib/commands/generators/create-service/index.d.ts +1 -0
- package/lib/commands/generators/create-service/index.js +5 -0
- package/lib/commands/generators/index.d.ts +7 -0
- package/lib/commands/generators/index.js +17 -0
- package/lib/commands/index.d.ts +6 -0
- package/lib/commands/index.js +23 -0
- package/lib/commands/rmdir/index.d.ts +1 -0
- package/lib/commands/rmdir/index.js +5 -0
- package/lib/commands/rmdir/rmdir-command.service.d.ts +12 -0
- package/lib/commands/rmdir/rmdir-command.service.js +29 -0
- package/lib/commands/run-script/index.d.ts +1 -0
- package/lib/commands/run-script/index.js +5 -0
- package/lib/commands/run-script/run-script-command.service.d.ts +10 -0
- package/lib/commands/run-script/run-script-command.service.js +79 -0
- package/lib/commands/upgrade/index.d.ts +1 -0
- package/lib/commands/upgrade/index.js +5 -0
- package/lib/commands/upgrade/upgrade-command.service.d.ts +24 -0
- package/lib/commands/upgrade/upgrade-command.service.js +49 -0
- package/lib/index.d.ts +1 -6
- package/lib/index.js +1 -157
- package/lib/services/crypto/crypto.service.d.ts +11 -0
- package/lib/services/crypto/crypto.service.js +20 -0
- package/lib/services/crypto/index.d.ts +1 -0
- package/lib/services/crypto/index.js +5 -0
- package/lib/services/file-system/file-system.service.d.ts +24 -0
- package/lib/services/file-system/file-system.service.js +89 -0
- package/lib/services/file-system/index.d.ts +1 -0
- package/lib/services/file-system/index.js +5 -0
- package/lib/{generate/file-system.d.ts → services/generator/generator.d.ts} +34 -41
- package/lib/{generate/file-system.js → services/generator/generator.js} +82 -112
- package/lib/services/generator/index.d.ts +1 -0
- package/lib/services/generator/index.js +6 -0
- package/lib/services/index.d.ts +5 -0
- package/lib/services/index.js +14 -0
- package/lib/services/logger/index.d.ts +1 -0
- package/lib/services/logger/index.js +5 -0
- package/lib/services/logger/logger.service.d.ts +8 -0
- package/lib/services/logger/logger.service.js +39 -0
- package/lib/services/util/index.d.ts +1 -0
- package/lib/services/util/index.js +5 -0
- package/lib/services/util/util.service.d.ts +12 -0
- package/lib/services/util/util.service.js +33 -0
- package/package.json +6 -9
- package/templates/file-system/test-template.txt +1 -0
- package/lib/create-secret/create-secret.d.ts +0 -7
- package/lib/create-secret/create-secret.js +0 -15
- package/lib/create-secret/index.d.ts +0 -1
- package/lib/create-secret/index.js +0 -5
- package/lib/generate/generators/angular/connect-angular.d.ts +0 -1
- package/lib/generate/generators/angular/connect-angular.js +0 -52
- package/lib/generate/generators/angular/index.d.ts +0 -1
- package/lib/generate/generators/angular/index.js +0 -5
- package/lib/generate/generators/app/create-app.d.ts +0 -7
- package/lib/generate/generators/app/create-app.js +0 -134
- package/lib/generate/generators/app/index.d.ts +0 -1
- package/lib/generate/generators/app/index.js +0 -5
- package/lib/generate/generators/controller/create-controller.d.ts +0 -4
- package/lib/generate/generators/controller/create-controller.js +0 -39
- package/lib/generate/generators/controller/index.d.ts +0 -1
- package/lib/generate/generators/controller/index.js +0 -5
- package/lib/generate/generators/entity/create-entity.d.ts +0 -3
- package/lib/generate/generators/entity/create-entity.js +0 -28
- package/lib/generate/generators/entity/index.d.ts +0 -1
- package/lib/generate/generators/entity/index.js +0 -5
- package/lib/generate/generators/hook/create-hook.d.ts +0 -3
- package/lib/generate/generators/hook/create-hook.js +0 -26
- package/lib/generate/generators/hook/index.d.ts +0 -1
- package/lib/generate/generators/hook/index.js +0 -5
- package/lib/generate/generators/index.d.ts +0 -11
- package/lib/generate/generators/index.js +0 -27
- package/lib/generate/generators/react/connect-react.d.ts +0 -1
- package/lib/generate/generators/react/connect-react.js +0 -33
- package/lib/generate/generators/react/index.d.ts +0 -1
- package/lib/generate/generators/react/index.js +0 -5
- package/lib/generate/generators/rest-api/create-rest-api.d.ts +0 -5
- package/lib/generate/generators/rest-api/create-rest-api.js +0 -63
- package/lib/generate/generators/rest-api/index.d.ts +0 -1
- package/lib/generate/generators/rest-api/index.js +0 -5
- package/lib/generate/generators/script/create-script.d.ts +0 -3
- package/lib/generate/generators/script/create-script.js +0 -15
- package/lib/generate/generators/script/index.d.ts +0 -1
- package/lib/generate/generators/script/index.js +0 -5
- package/lib/generate/generators/service/create-service.d.ts +0 -3
- package/lib/generate/generators/service/create-service.js +0 -26
- package/lib/generate/generators/service/index.d.ts +0 -1
- package/lib/generate/generators/service/index.js +0 -5
- package/lib/generate/generators/upgrade/index.d.ts +0 -1
- package/lib/generate/generators/upgrade/index.js +0 -5
- package/lib/generate/generators/upgrade/upgrade.d.ts +0 -8
- package/lib/generate/generators/upgrade/upgrade.js +0 -34
- package/lib/generate/generators/vue/connect-vue.d.ts +0 -1
- package/lib/generate/generators/vue/connect-vue.js +0 -37
- package/lib/generate/generators/vue/index.d.ts +0 -1
- package/lib/generate/generators/vue/index.js +0 -5
- package/lib/generate/index.d.ts +0 -1
- package/lib/generate/index.js +0 -17
- package/lib/rmdir/index.d.ts +0 -1
- package/lib/rmdir/index.js +0 -5
- package/lib/rmdir/rmdir.util.d.ts +0 -8
- package/lib/rmdir/rmdir.util.js +0 -24
- package/lib/run/get-command-line-arguments.util.d.ts +0 -1
- package/lib/run/get-command-line-arguments.util.js +0 -21
- package/lib/run/index.d.ts +0 -1
- package/lib/run/index.js +0 -5
- package/lib/run/run-script.d.ts +0 -7
- package/lib/run/run-script.js +0 -76
- /package/lib/{generate → commands/generators}/utils/get-names.d.ts +0 -0
- /package/lib/{generate → commands/generators}/utils/get-names.js +0 -0
- /package/lib/{generate → commands/generators}/utils/index.d.ts +0 -0
- /package/lib/{generate → commands/generators}/utils/index.js +0 -0
- /package/lib/{generate → commands/generators}/utils/init-git-repo.d.ts +0 -0
- /package/lib/{generate → commands/generators}/utils/init-git-repo.js +0 -0
- /package/lib/{generate → commands/generators}/utils/install-dependencies.d.ts +0 -0
- /package/lib/{generate → commands/generators}/utils/install-dependencies.js +0 -0
- /package/lib/{generate → commands/generators}/utils/logger.d.ts +0 -0
- /package/lib/{generate → commands/generators}/utils/logger.js +0 -0
- /package/lib/{generate → commands/generators}/utils/mkdir-if-does-not-exist.d.ts +0 -0
- /package/lib/{generate → commands/generators}/utils/mkdir-if-does-not-exist.js +0 -0
- /package/lib/{generate → commands/generators}/utils/rm-dir-and-files-if-exist.d.ts +0 -0
- /package/lib/{generate → commands/generators}/utils/rm-dir-and-files-if-exist.js +0 -0
package/lib/cli.d.ts
ADDED
package/lib/cli.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FoalTS
|
|
4
|
+
* Copyright(c) 2017-2025 Loïc Poullain
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
// 3p
|
|
9
|
+
const safe_1 = require("colors/safe");
|
|
10
|
+
const commander_1 = require("commander");
|
|
11
|
+
// FoalTS
|
|
12
|
+
const services_1 = require("./services");
|
|
13
|
+
const commands_1 = require("./commands");
|
|
14
|
+
function displayError(...lines) {
|
|
15
|
+
console.error();
|
|
16
|
+
lines.forEach(line => console.error((0, safe_1.red)(line)));
|
|
17
|
+
console.error();
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
}
|
|
20
|
+
// tslint:disable-next-line:no-var-requires
|
|
21
|
+
const pkg = require('../package.json');
|
|
22
|
+
commander_1.program
|
|
23
|
+
.version(pkg.version, '-v, --version');
|
|
24
|
+
commander_1.program
|
|
25
|
+
.command('createapp')
|
|
26
|
+
.argument('<name>', 'Name of the application')
|
|
27
|
+
.description('Create a new project.')
|
|
28
|
+
.option('-G, --no-git', 'Don\'t initialize a git repository')
|
|
29
|
+
.option('-I, --no-install', 'Don\'t autoinstall packages using yarn or npm (uses first available)')
|
|
30
|
+
.option('-m, --mongodb', 'Generate a new project using MongoDB instead of SQLite', false)
|
|
31
|
+
.option('-y, --yaml', 'Generate a new project using YAML configuration instead of JSON', false)
|
|
32
|
+
.action(async (name, options) => {
|
|
33
|
+
const fileSystem = new services_1.FileSystemService();
|
|
34
|
+
const logger = new services_1.LoggerService();
|
|
35
|
+
const generator = new services_1.Generator(fileSystem, logger);
|
|
36
|
+
const createAppCommandService = new commands_1.CreateAppCommandService(generator);
|
|
37
|
+
await createAppCommandService.run({
|
|
38
|
+
autoInstall: options.install,
|
|
39
|
+
initRepo: options.git,
|
|
40
|
+
mongodb: options.mongodb,
|
|
41
|
+
name,
|
|
42
|
+
yaml: options.yaml
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
commander_1.program
|
|
46
|
+
.command('createsecret')
|
|
47
|
+
.description('Create a 256-bit random secret encoded in base64.')
|
|
48
|
+
.action(async () => {
|
|
49
|
+
const cryptoService = new services_1.CryptoService();
|
|
50
|
+
const loggerService = new services_1.LoggerService();
|
|
51
|
+
const createSecretCommandService = new commands_1.CreateSecretCommandService(cryptoService, loggerService);
|
|
52
|
+
await createSecretCommandService.run();
|
|
53
|
+
});
|
|
54
|
+
commander_1.program
|
|
55
|
+
.command('run')
|
|
56
|
+
.argument('<name>', 'Name of the script to run')
|
|
57
|
+
.argument('[args...]', 'Script arguments (key=value format)')
|
|
58
|
+
.description('Run a shell script.')
|
|
59
|
+
.action(async (name) => {
|
|
60
|
+
const utilService = new services_1.UtilService();
|
|
61
|
+
const runScriptCommandService = new commands_1.RunScriptCommandService(utilService);
|
|
62
|
+
await runScriptCommandService.run(name, process.argv);
|
|
63
|
+
});
|
|
64
|
+
commander_1.program
|
|
65
|
+
.command('connect')
|
|
66
|
+
.argument('<framework>', 'Frontend framework to connect to')
|
|
67
|
+
.argument('<path>', 'Path to the frontend project')
|
|
68
|
+
.description('Configure your frontend to interact with your application.')
|
|
69
|
+
.addHelpText('after', `
|
|
70
|
+
Available frameworks:
|
|
71
|
+
- angular
|
|
72
|
+
- react
|
|
73
|
+
- vue
|
|
74
|
+
`)
|
|
75
|
+
.action(async (framework, path) => {
|
|
76
|
+
switch (framework) {
|
|
77
|
+
case 'angular':
|
|
78
|
+
const fileSystem = new services_1.FileSystemService();
|
|
79
|
+
const logger = new services_1.LoggerService();
|
|
80
|
+
const generator = new services_1.Generator(fileSystem, logger);
|
|
81
|
+
const connectAngularCommandService = new commands_1.ConnectAngularCommandService(generator);
|
|
82
|
+
connectAngularCommandService.run(path);
|
|
83
|
+
break;
|
|
84
|
+
case 'react':
|
|
85
|
+
const reactFileSystem = new services_1.FileSystemService();
|
|
86
|
+
const reactLogger = new services_1.LoggerService();
|
|
87
|
+
const reactGenerator = new services_1.Generator(reactFileSystem, reactLogger);
|
|
88
|
+
const connectReactCommandService = new commands_1.ConnectReactCommandService(reactGenerator);
|
|
89
|
+
connectReactCommandService.run(path);
|
|
90
|
+
break;
|
|
91
|
+
case 'vue':
|
|
92
|
+
const vueFileSystem = new services_1.FileSystemService();
|
|
93
|
+
const vueLogger = new services_1.LoggerService();
|
|
94
|
+
const vueGenerator = new services_1.Generator(vueFileSystem, vueLogger);
|
|
95
|
+
const connectVueCommandService = new commands_1.ConnectVueCommandService(vueGenerator);
|
|
96
|
+
connectVueCommandService.run(path);
|
|
97
|
+
break;
|
|
98
|
+
default:
|
|
99
|
+
displayError(`Unknown framework ${(0, safe_1.yellow)(framework)}. Please provide a valid one:`, '', ' - angular', ' - react', ' - vue');
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
const generateTypes = [
|
|
103
|
+
'controller', 'entity', 'rest-api', 'hook', 'script', 'service'
|
|
104
|
+
];
|
|
105
|
+
commander_1.program
|
|
106
|
+
.command('generate')
|
|
107
|
+
.argument('<type>', 'Type of the file to generate')
|
|
108
|
+
.argument('<name>', 'Name of the file to generate')
|
|
109
|
+
.description('Generate and/or modify files.')
|
|
110
|
+
.option('-r, --register', 'Register the controller into app.controller.ts (only available if type=controller|rest-api)', false)
|
|
111
|
+
.option('-a, --auth', 'Add an owner to the entities of the generated REST API (only available if type=rest-api)', false)
|
|
112
|
+
.alias('g')
|
|
113
|
+
.addHelpText('after', `
|
|
114
|
+
Available types:
|
|
115
|
+
${generateTypes.map(t => ` - ${t}`).join('\n')}
|
|
116
|
+
`)
|
|
117
|
+
.action(async (type, name, options) => {
|
|
118
|
+
try {
|
|
119
|
+
switch (type) {
|
|
120
|
+
case 'controller':
|
|
121
|
+
const controllerFileSystem = new services_1.FileSystemService();
|
|
122
|
+
const controllerLogger = new services_1.LoggerService();
|
|
123
|
+
const controllerGenerator = new services_1.Generator(controllerFileSystem, controllerLogger);
|
|
124
|
+
const createControllerCommandService = new commands_1.CreateControllerCommandService(controllerGenerator);
|
|
125
|
+
createControllerCommandService.run({ name, register: options.register });
|
|
126
|
+
break;
|
|
127
|
+
case 'entity':
|
|
128
|
+
const entityFileSystem = new services_1.FileSystemService();
|
|
129
|
+
const entityLogger = new services_1.LoggerService();
|
|
130
|
+
const entityGenerator = new services_1.Generator(entityFileSystem, entityLogger);
|
|
131
|
+
const createEntityCommandService = new commands_1.CreateEntityCommandService(entityGenerator);
|
|
132
|
+
createEntityCommandService.run({ name });
|
|
133
|
+
break;
|
|
134
|
+
case 'rest-api':
|
|
135
|
+
const restApiFileSystem = new services_1.FileSystemService();
|
|
136
|
+
const restApiLogger = new services_1.LoggerService();
|
|
137
|
+
const restApiGenerator = new services_1.Generator(restApiFileSystem, restApiLogger);
|
|
138
|
+
const createRestApiCommandService = new commands_1.CreateRestApiCommandService(restApiGenerator);
|
|
139
|
+
createRestApiCommandService.run({ name, register: options.register, auth: options.auth });
|
|
140
|
+
break;
|
|
141
|
+
case 'hook':
|
|
142
|
+
const hookFileSystem = new services_1.FileSystemService();
|
|
143
|
+
const hookLogger = new services_1.LoggerService();
|
|
144
|
+
const hookGenerator = new services_1.Generator(hookFileSystem, hookLogger);
|
|
145
|
+
const createHookCommandService = new commands_1.CreateHookCommandService(hookGenerator);
|
|
146
|
+
createHookCommandService.run({ name });
|
|
147
|
+
break;
|
|
148
|
+
case 'script':
|
|
149
|
+
const scriptFileSystem = new services_1.FileSystemService();
|
|
150
|
+
const scriptLogger = new services_1.LoggerService();
|
|
151
|
+
const scriptGenerator = new services_1.Generator(scriptFileSystem, scriptLogger);
|
|
152
|
+
const createScriptCommandService = new commands_1.CreateScriptCommandService(scriptGenerator);
|
|
153
|
+
createScriptCommandService.run({ name });
|
|
154
|
+
break;
|
|
155
|
+
case 'service':
|
|
156
|
+
const serviceFileSystem = new services_1.FileSystemService();
|
|
157
|
+
const serviceLogger = new services_1.LoggerService();
|
|
158
|
+
const serviceGenerator = new services_1.Generator(serviceFileSystem, serviceLogger);
|
|
159
|
+
const createServiceCommandService = new commands_1.CreateServiceCommandService(serviceGenerator);
|
|
160
|
+
createServiceCommandService.run({ name });
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
displayError(`Unknown type ${(0, safe_1.yellow)(type)}. Please provide a valid one:`, '', ...generateTypes.map(t => ` - ${t}`));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (error instanceof services_1.ClientError) {
|
|
168
|
+
displayError(error.message);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
commander_1.program
|
|
175
|
+
.command('rmdir')
|
|
176
|
+
.argument('<name>', 'Name of the directory to remove')
|
|
177
|
+
.description('Remove a directory and all its contents, including any subdirectories and files.')
|
|
178
|
+
.action(async (name) => {
|
|
179
|
+
try {
|
|
180
|
+
const rmdirCommandService = new commands_1.RmdirCommandService();
|
|
181
|
+
await rmdirCommandService.run(name);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
if (error.code === 'ENOTDIR') {
|
|
185
|
+
displayError(error.message);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
commander_1.program
|
|
192
|
+
.command('upgrade')
|
|
193
|
+
.argument('[version]', 'Name of the specific version to upgrade to')
|
|
194
|
+
.description('Upgrade the project to the latest version of FoalTS. If a version is provided, upgrade to that version.')
|
|
195
|
+
.option('-I, --no-install', 'Don\'t autoinstall packages using yarn or npm (uses first available)')
|
|
196
|
+
.action(async (version, options) => {
|
|
197
|
+
const upgradeFileSystem = new services_1.FileSystemService();
|
|
198
|
+
const upgradeLogger = new services_1.LoggerService();
|
|
199
|
+
const upgradeGenerator = new services_1.Generator(upgradeFileSystem, upgradeLogger);
|
|
200
|
+
const upgradeCommandService = new commands_1.UpgradeCommandService(upgradeGenerator);
|
|
201
|
+
await upgradeCommandService.run({ version, autoInstall: options.install });
|
|
202
|
+
});
|
|
203
|
+
commander_1.program
|
|
204
|
+
.on('command:*', (commands) => {
|
|
205
|
+
commander_1.program.outputHelp();
|
|
206
|
+
displayError(`Unknown command ${(0, safe_1.yellow)(commands[0])}.`);
|
|
207
|
+
});
|
|
208
|
+
commander_1.program.parse(process.argv);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Generator } from '../../../services';
|
|
2
|
+
/**
|
|
3
|
+
* Service for connecting an Angular frontend to a FoalTS application.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConnectAngularCommandService {
|
|
6
|
+
private generator;
|
|
7
|
+
constructor(generator: Generator);
|
|
8
|
+
/**
|
|
9
|
+
* Configure an Angular project to interact with a FoalTS application.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} path - The path to the Angular project directory
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
run(path: string): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectAngularCommandService = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const safe_1 = require("colors/safe");
|
|
6
|
+
/**
|
|
7
|
+
* Service for connecting an Angular frontend to a FoalTS application.
|
|
8
|
+
*/
|
|
9
|
+
class ConnectAngularCommandService {
|
|
10
|
+
generator;
|
|
11
|
+
constructor(generator) {
|
|
12
|
+
this.generator = generator;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Configure an Angular project to interact with a FoalTS application.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} path - The path to the Angular project directory
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
20
|
+
run(path) {
|
|
21
|
+
if (!this.generator.exists(path)) {
|
|
22
|
+
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
23
|
+
console.log((0, safe_1.red)(` The directory ${path} does not exist.`));
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!this.generator.exists((0, path_1.join)(path, 'angular.json'))) {
|
|
28
|
+
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
29
|
+
console.log((0, safe_1.red)(` The directory ${path} is not an Angular project (missing angular.json).`));
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!this.generator.exists((0, path_1.join)(path, 'package.json'))) {
|
|
34
|
+
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
35
|
+
console.log((0, safe_1.red)(` The directory ${path} is not an Angular project (missing package.json).`));
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this.generator
|
|
40
|
+
.cd(path)
|
|
41
|
+
.copyTemplate('angular/proxy.conf.json', 'src/proxy.conf.json')
|
|
42
|
+
.modify('package.json', content => {
|
|
43
|
+
const pkg = JSON.parse(content);
|
|
44
|
+
pkg.scripts.build = 'ng build --prod';
|
|
45
|
+
return JSON.stringify(pkg, null, 2);
|
|
46
|
+
})
|
|
47
|
+
.modify('angular.json', content => {
|
|
48
|
+
const config = JSON.parse(content);
|
|
49
|
+
const projectName = Object.keys(config.projects)[0];
|
|
50
|
+
// Proxy configuration
|
|
51
|
+
config.projects[projectName].architect ||= {};
|
|
52
|
+
config.projects[projectName].architect.serve ||= {};
|
|
53
|
+
config.projects[projectName].architect.serve.options ||= {};
|
|
54
|
+
config.projects[projectName].architect.serve.options.proxyConfig = 'src/proxy.conf.json';
|
|
55
|
+
// Output build directory
|
|
56
|
+
const outputPath = (0, path_1.join)((0, path_1.relative)(path, process.cwd()), 'public')
|
|
57
|
+
// Make projects generated on Windows build on Unix.
|
|
58
|
+
.replace(/\\/g, '/');
|
|
59
|
+
config.projects[projectName].architect.build ||= {};
|
|
60
|
+
config.projects[projectName].architect.build.options ||= {};
|
|
61
|
+
config.projects[projectName].architect.build.options.outputPath = outputPath;
|
|
62
|
+
return JSON.stringify(config, null, 2);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ConnectAngularCommandService = ConnectAngularCommandService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ConnectAngularCommandService } from './connect-angular-command.service';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectAngularCommandService = void 0;
|
|
4
|
+
var connect_angular_command_service_1 = require("./connect-angular-command.service");
|
|
5
|
+
Object.defineProperty(exports, "ConnectAngularCommandService", { enumerable: true, get: function () { return connect_angular_command_service_1.ConnectAngularCommandService; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Generator } from '../../../services';
|
|
2
|
+
/**
|
|
3
|
+
* Service for connecting a React frontend to a FoalTS application.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConnectReactCommandService {
|
|
6
|
+
private generator;
|
|
7
|
+
constructor(generator: Generator);
|
|
8
|
+
/**
|
|
9
|
+
* Configure a React project to interact with a FoalTS application.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} path - The path to the React project directory
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
run(path: string): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectReactCommandService = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const safe_1 = require("colors/safe");
|
|
6
|
+
/**
|
|
7
|
+
* Service for connecting a React frontend to a FoalTS application.
|
|
8
|
+
*/
|
|
9
|
+
class ConnectReactCommandService {
|
|
10
|
+
generator;
|
|
11
|
+
constructor(generator) {
|
|
12
|
+
this.generator = generator;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Configure a React project to interact with a FoalTS application.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} path - The path to the React project directory
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
20
|
+
run(path) {
|
|
21
|
+
if (!this.generator.exists(path)) {
|
|
22
|
+
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
23
|
+
console.log((0, safe_1.red)(` The directory ${path} does not exist.`));
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!this.generator.exists((0, path_1.join)(path, 'package.json'))) {
|
|
28
|
+
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
29
|
+
console.log((0, safe_1.red)(` The directory ${path} is not a React project (missing package.json).`));
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const outputPath = (0, path_1.join)((0, path_1.relative)(path, process.cwd()), 'public')
|
|
34
|
+
// Make projects generated on Windows build on Unix.
|
|
35
|
+
.replace(/\\/g, '/');
|
|
36
|
+
this.generator
|
|
37
|
+
.cd(path)
|
|
38
|
+
.modify('package.json', content => {
|
|
39
|
+
const pkg = JSON.parse(content);
|
|
40
|
+
pkg.proxy = 'http://localhost:3001';
|
|
41
|
+
return JSON.stringify(pkg, null, 2);
|
|
42
|
+
})
|
|
43
|
+
.copyTemplate('react/env.development', '.env.development')
|
|
44
|
+
.render('react/env', '.env', { path: outputPath });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.ConnectReactCommandService = ConnectReactCommandService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ConnectReactCommandService } from './connect-react-command.service';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectReactCommandService = void 0;
|
|
4
|
+
var connect_react_command_service_1 = require("./connect-react-command.service");
|
|
5
|
+
Object.defineProperty(exports, "ConnectReactCommandService", { enumerable: true, get: function () { return connect_react_command_service_1.ConnectReactCommandService; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Generator } from '../../../services';
|
|
2
|
+
/**
|
|
3
|
+
* Service for connecting a Vue frontend to a FoalTS application.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConnectVueCommandService {
|
|
6
|
+
private generator;
|
|
7
|
+
constructor(generator: Generator);
|
|
8
|
+
/**
|
|
9
|
+
* Configure a Vue project to interact with a FoalTS application.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} path - The path to the Vue project directory
|
|
12
|
+
* @returns {void}
|
|
13
|
+
*/
|
|
14
|
+
run(path: string): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectVueCommandService = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const safe_1 = require("colors/safe");
|
|
6
|
+
/**
|
|
7
|
+
* Service for connecting a Vue frontend to a FoalTS application.
|
|
8
|
+
*/
|
|
9
|
+
class ConnectVueCommandService {
|
|
10
|
+
generator;
|
|
11
|
+
constructor(generator) {
|
|
12
|
+
this.generator = generator;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Configure a Vue project to interact with a FoalTS application.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} path - The path to the Vue project directory
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
20
|
+
run(path) {
|
|
21
|
+
if (!this.generator.exists(path)) {
|
|
22
|
+
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
23
|
+
console.log((0, safe_1.red)(` The directory ${path} does not exist.`));
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!this.generator.exists((0, path_1.join)(path, 'package.json'))) {
|
|
28
|
+
if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') {
|
|
29
|
+
console.log((0, safe_1.red)(` The directory ${path} is not a Vue project (missing package.json).`));
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.generator
|
|
34
|
+
.cd(path)
|
|
35
|
+
.modify('package.json', content => {
|
|
36
|
+
const pkg = JSON.parse(content);
|
|
37
|
+
pkg.vue = pkg.vue || {};
|
|
38
|
+
// Proxy configuration
|
|
39
|
+
pkg.vue.devServer = pkg.vue.devServer || {};
|
|
40
|
+
pkg.vue.devServer.proxy = pkg.vue.devServer.proxy || {};
|
|
41
|
+
pkg.vue.devServer.proxy['^/api'] = { target: 'http://localhost:3001' };
|
|
42
|
+
// Output build directory
|
|
43
|
+
const outputPath = (0, path_1.join)((0, path_1.relative)(path, process.cwd()), 'public')
|
|
44
|
+
// Make projects generated on Windows build on Unix.
|
|
45
|
+
.replace(/\\/g, '/');
|
|
46
|
+
pkg.vue.outputDir = outputPath;
|
|
47
|
+
return JSON.stringify(pkg, null, 2);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.ConnectVueCommandService = ConnectVueCommandService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ConnectVueCommandService } from './connect-vue-command.service';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectVueCommandService = void 0;
|
|
4
|
+
var connect_vue_command_service_1 = require("./connect-vue-command.service");
|
|
5
|
+
Object.defineProperty(exports, "ConnectVueCommandService", { enumerable: true, get: function () { return connect_vue_command_service_1.ConnectVueCommandService; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectVueCommandService = exports.ConnectReactCommandService = exports.ConnectAngularCommandService = void 0;
|
|
4
|
+
var connect_angular_1 = require("./connect-angular");
|
|
5
|
+
Object.defineProperty(exports, "ConnectAngularCommandService", { enumerable: true, get: function () { return connect_angular_1.ConnectAngularCommandService; } });
|
|
6
|
+
var connect_react_1 = require("./connect-react");
|
|
7
|
+
Object.defineProperty(exports, "ConnectReactCommandService", { enumerable: true, get: function () { return connect_react_1.ConnectReactCommandService; } });
|
|
8
|
+
var connect_vue_1 = require("./connect-vue");
|
|
9
|
+
Object.defineProperty(exports, "ConnectVueCommandService", { enumerable: true, get: function () { return connect_vue_1.ConnectVueCommandService; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateSecretCommandService = void 0;
|
|
4
|
+
class CreateSecretCommandService {
|
|
5
|
+
cryptoService;
|
|
6
|
+
loggerService;
|
|
7
|
+
constructor(cryptoService, loggerService) {
|
|
8
|
+
this.cryptoService = cryptoService;
|
|
9
|
+
this.loggerService = loggerService;
|
|
10
|
+
}
|
|
11
|
+
async run() {
|
|
12
|
+
const secret = await this.cryptoService.createSecret();
|
|
13
|
+
this.loggerService.info(`New secret: ${secret}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.CreateSecretCommandService = CreateSecretCommandService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CreateSecretCommandService } from './create-secret-command.service';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateSecretCommandService = void 0;
|
|
4
|
+
var create_secret_command_service_1 = require("./create-secret-command.service");
|
|
5
|
+
Object.defineProperty(exports, "CreateSecretCommandService", { enumerable: true, get: function () { return create_secret_command_service_1.CreateSecretCommandService; } });
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Generator } from '../../../services';
|
|
2
|
+
/**
|
|
3
|
+
* Service for creating a new FoalTS application.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CreateAppCommandService {
|
|
6
|
+
private generator;
|
|
7
|
+
constructor(generator: Generator);
|
|
8
|
+
/**
|
|
9
|
+
* Create a new FoalTS application.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} name - The name of the application
|
|
12
|
+
* @param {boolean} autoInstall - Whether to automatically install dependencies
|
|
13
|
+
* @param {boolean} initRepo - Whether to initialize a git repository
|
|
14
|
+
* @param {boolean} mongodb - Whether to use MongoDB instead of SQLite
|
|
15
|
+
* @param {boolean} yaml - Whether to use YAML configuration instead of JSON
|
|
16
|
+
* @returns {Promise<void>}
|
|
17
|
+
*/
|
|
18
|
+
run({ name, autoInstall, initRepo, mongodb, yaml }: {
|
|
19
|
+
name: string;
|
|
20
|
+
autoInstall?: boolean;
|
|
21
|
+
initRepo?: boolean;
|
|
22
|
+
mongodb?: boolean;
|
|
23
|
+
yaml?: boolean;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
}
|