authup 1.0.0-beta.2 → 1.0.0-beta.21
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/LICENSE +201 -21
- package/README.md +1 -1
- package/dist/index.cjs +293 -272
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +293 -272
- package/dist/index.mjs.map +1 -1
- package/dist/module.d.ts +22 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/packages/client-web/config/build.d.ts +3 -0
- package/dist/packages/client-web/config/build.d.ts.map +1 -0
- package/dist/packages/client-web/config/index.d.ts +3 -0
- package/dist/packages/client-web/config/index.d.ts.map +1 -0
- package/dist/packages/client-web/config/parse.d.ts +3 -0
- package/dist/packages/client-web/config/parse.d.ts.map +1 -0
- package/dist/packages/client-web/config/read/env.d.ts +3 -0
- package/dist/packages/client-web/config/read/env.d.ts.map +1 -0
- package/dist/packages/client-web/config/read/fs.d.ts +7 -0
- package/dist/packages/client-web/config/read/fs.d.ts.map +1 -0
- package/dist/packages/client-web/config/read/index.d.ts +2 -0
- package/dist/packages/client-web/config/read/index.d.ts.map +1 -0
- package/dist/packages/client-web/config/read/module.d.ts +8 -0
- package/dist/packages/client-web/config/read/module.d.ts.map +1 -0
- package/dist/packages/client-web/config/type.d.ts +9 -0
- package/dist/packages/client-web/config/type.d.ts.map +1 -0
- package/dist/packages/client-web/index.d.ts +3 -0
- package/dist/packages/client-web/index.d.ts.map +1 -0
- package/dist/packages/client-web/module.d.ts +9 -0
- package/dist/packages/client-web/module.d.ts.map +1 -0
- package/dist/packages/constants.d.ts +9 -0
- package/dist/packages/constants.d.ts.map +1 -0
- package/dist/packages/execute.d.ts +4 -0
- package/dist/packages/execute.d.ts.map +1 -0
- package/dist/packages/index.d.ts +6 -0
- package/dist/packages/index.d.ts.map +1 -0
- package/dist/packages/normalize.d.ts +3 -0
- package/dist/packages/normalize.d.ts.map +1 -0
- package/dist/packages/server-core/index.d.ts +2 -0
- package/dist/packages/server-core/index.d.ts.map +1 -0
- package/dist/packages/server-core/module.d.ts +7 -0
- package/dist/packages/server-core/module.d.ts.map +1 -0
- package/dist/packages/types.d.ts +9 -0
- package/dist/packages/types.d.ts.map +1 -0
- package/dist/utils/shell.d.ts +4 -4
- package/dist/utils/shell.d.ts.map +1 -1
- package/package.json +13 -12
- package/dist/commands/cleanup.d.ts +0 -3
- package/dist/commands/cleanup.d.ts.map +0 -1
- package/dist/commands/index.d.ts +0 -4
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/info.d.ts +0 -3
- package/dist/commands/info.d.ts.map +0 -1
- package/dist/commands/start.d.ts +0 -3
- package/dist/commands/start.d.ts.map +0 -1
- package/dist/services/check.d.ts +0 -3
- package/dist/services/check.d.ts.map +0 -1
- package/dist/services/client-web/config.d.ts +0 -4
- package/dist/services/client-web/config.d.ts.map +0 -1
- package/dist/services/client-web/execute.d.ts +0 -8
- package/dist/services/client-web/execute.d.ts.map +0 -1
- package/dist/services/client-web/index.d.ts +0 -3
- package/dist/services/client-web/index.d.ts.map +0 -1
- package/dist/services/constants.d.ts +0 -9
- package/dist/services/constants.d.ts.map +0 -1
- package/dist/services/execute.d.ts +0 -9
- package/dist/services/execute.d.ts.map +0 -1
- package/dist/services/index.d.ts +0 -5
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/server-core/config.d.ts +0 -4
- package/dist/services/server-core/config.d.ts.map +0 -1
- package/dist/services/server-core/execute.d.ts +0 -3
- package/dist/services/server-core/execute.d.ts.map +0 -1
- package/dist/services/server-core/index.d.ts +0 -3
- package/dist/services/server-core/index.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,68 +1,131 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var consola = require('consola');
|
|
7
|
-
var clientWebConfig = require('@authup/client-web-config');
|
|
8
|
-
var core = require('@authup/core');
|
|
4
|
+
var citty = require('citty');
|
|
5
|
+
var fs = require('node:fs');
|
|
9
6
|
var path = require('node:path');
|
|
10
|
-
var node_child_process = require('node:child_process');
|
|
11
7
|
var process = require('node:process');
|
|
8
|
+
var kit = require('@authup/kit');
|
|
9
|
+
var dycraft = require('dycraft');
|
|
10
|
+
var zod = require('zod');
|
|
12
11
|
var smob = require('smob');
|
|
12
|
+
var envix = require('envix');
|
|
13
|
+
var confinity = require('confinity');
|
|
14
|
+
var consola = require('consola');
|
|
15
|
+
var node_child_process = require('node:child_process');
|
|
13
16
|
var findUpPackagePath = require('resolve-package-path');
|
|
14
|
-
var serverCore = require('@authup/server-core');
|
|
15
|
-
var readline = require('node:readline');
|
|
16
|
-
var chalk = require('chalk');
|
|
17
17
|
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
function parseClientWebConfig(input = {}) {
|
|
19
|
+
const schema = zod.object({
|
|
20
|
+
port: zod.number().nonnegative().optional(),
|
|
21
|
+
host: zod.string().optional(),
|
|
22
|
+
apiUrl: zod.string().url().optional(),
|
|
23
|
+
publicUrl: zod.string().url().optional()
|
|
24
|
+
});
|
|
25
|
+
return schema.parse(input);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function buildClientWebConfig(raw) {
|
|
29
|
+
const config = dycraft.dycraft({
|
|
30
|
+
defaults: {
|
|
31
|
+
port: 3000,
|
|
32
|
+
host: '0.0.0.0',
|
|
33
|
+
apiUrl: 'http://127.0.0.1:3001/'
|
|
34
|
+
},
|
|
35
|
+
getters: {
|
|
36
|
+
publicUrl: dycraft.defineGetter((context)=>`http://${kit.makeURLPublicAccessible(context.get('host'))}:${context.get('port')}/`)
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return kit.extendObject(config, parseClientWebConfig(raw));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function readClientWebConfigFromEnv() {
|
|
43
|
+
const config = {};
|
|
44
|
+
const port = envix.oneOf([
|
|
45
|
+
envix.readInt('UI_PORT'),
|
|
46
|
+
envix.readInt('NITRO_UI_PORT'),
|
|
47
|
+
envix.readInt('NUXT_UI_PORT'),
|
|
48
|
+
envix.readInt('NUXT_PUBLIC_UI_PORT'),
|
|
49
|
+
envix.readInt('PORT'),
|
|
50
|
+
envix.readInt('NITRO_PORT'),
|
|
51
|
+
envix.readInt('NUXT_PORT'),
|
|
52
|
+
envix.readInt('NUXT_PUBLIC_PORT')
|
|
53
|
+
]);
|
|
54
|
+
if (typeof port !== 'undefined') {
|
|
55
|
+
config.port = port;
|
|
56
|
+
}
|
|
57
|
+
const host = envix.oneOf([
|
|
58
|
+
envix.read('HOST'),
|
|
59
|
+
envix.read('NITRO_HOST'),
|
|
60
|
+
envix.read('NUXT_HOST')
|
|
61
|
+
]);
|
|
62
|
+
if (host) {
|
|
63
|
+
config.host = host;
|
|
24
64
|
}
|
|
25
|
-
|
|
26
|
-
|
|
65
|
+
const apiUrl = envix.oneOf([
|
|
66
|
+
envix.read('API_URL'),
|
|
67
|
+
envix.read('NUXT_API_URL'),
|
|
68
|
+
envix.read('NUXT_PUBLIC_API_URL')
|
|
69
|
+
]);
|
|
70
|
+
if (apiUrl) {
|
|
71
|
+
config.apiUrl = apiUrl;
|
|
27
72
|
}
|
|
28
|
-
|
|
29
|
-
|
|
73
|
+
const publicURL = envix.oneOf([
|
|
74
|
+
envix.read('PUBLIC_URL'),
|
|
75
|
+
envix.read('NUXT_PUBLIC_URL'),
|
|
76
|
+
envix.read('NUXT_PUBLIC_PUBLIC_URL')
|
|
77
|
+
]);
|
|
78
|
+
if (publicURL) {
|
|
79
|
+
config.publicUrl = publicURL;
|
|
30
80
|
}
|
|
31
|
-
return
|
|
81
|
+
return config;
|
|
32
82
|
}
|
|
33
83
|
|
|
34
|
-
async function
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
84
|
+
async function readClientWebConfigFromFS(options = {}) {
|
|
85
|
+
const container = new confinity.Container({
|
|
86
|
+
prefix: 'authup',
|
|
87
|
+
cwd: options.cwd
|
|
88
|
+
});
|
|
89
|
+
if (options.file) {
|
|
90
|
+
await container.loadFile(options.file);
|
|
91
|
+
} else {
|
|
92
|
+
await container.load();
|
|
93
|
+
}
|
|
94
|
+
const clientRaw = container.get('client.web') || {};
|
|
95
|
+
const serverRaw = container.get('server.core') || {};
|
|
96
|
+
if (serverRaw) {
|
|
97
|
+
if (!clientRaw.apiUrl && typeof serverRaw.publicUrl === 'string') {
|
|
98
|
+
clientRaw.apiUrl = kit.makeURLPublicAccessible(serverRaw.publicUrl);
|
|
40
99
|
}
|
|
41
|
-
if (!
|
|
42
|
-
|
|
100
|
+
if (!clientRaw.publicUrl && typeof serverRaw.authorizeRedirectUrl === 'string') {
|
|
101
|
+
clientRaw.apiUrl = kit.makeURLPublicAccessible(serverRaw.authorizeRedirectUrl);
|
|
43
102
|
}
|
|
44
103
|
}
|
|
45
|
-
return
|
|
46
|
-
data: client,
|
|
47
|
-
env: true
|
|
48
|
-
});
|
|
104
|
+
return clientRaw;
|
|
49
105
|
}
|
|
50
106
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
107
|
+
async function readClientWebConfigRaw(options = {}) {
|
|
108
|
+
if (options.fs && options.env) {
|
|
109
|
+
const fsOptions = boolableToObject(options.fs);
|
|
110
|
+
const fs = await readClientWebConfigFromFS(fsOptions);
|
|
111
|
+
const env = readClientWebConfigFromEnv();
|
|
112
|
+
return smob.merge(env, fs);
|
|
113
|
+
}
|
|
114
|
+
if (options.fs) {
|
|
115
|
+
const fsOptions = boolableToObject(options.fs);
|
|
116
|
+
return readClientWebConfigFromFS(fsOptions);
|
|
117
|
+
}
|
|
118
|
+
if (options.env) {
|
|
119
|
+
return readClientWebConfigFromEnv();
|
|
120
|
+
}
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
123
|
+
function boolableToObject(input) {
|
|
124
|
+
if (typeof input === 'boolean') {
|
|
125
|
+
return {};
|
|
126
|
+
}
|
|
127
|
+
return input;
|
|
128
|
+
}
|
|
66
129
|
|
|
67
130
|
/*
|
|
68
131
|
* Copyright (c) 2022.
|
|
@@ -86,7 +149,7 @@ function parseProcessOutputData(input) {
|
|
|
86
149
|
}
|
|
87
150
|
try {
|
|
88
151
|
const parsed = JSON.parse(line);
|
|
89
|
-
if (
|
|
152
|
+
if (kit.isObject(parsed) && kit.hasOwnProperty(parsed, 'message') && typeof parsed.message === 'string') {
|
|
90
153
|
items.push(parsed.message);
|
|
91
154
|
continue;
|
|
92
155
|
}
|
|
@@ -112,15 +175,13 @@ function parseProcessOutputData(input) {
|
|
|
112
175
|
return parts.join(' ');
|
|
113
176
|
}
|
|
114
177
|
|
|
115
|
-
async function execShellCommand(ctx) {
|
|
116
|
-
ctx.env = ctx.env || {};
|
|
117
|
-
ctx.args = ctx.args || {};
|
|
178
|
+
async function execShellCommand(command, ctx = {}) {
|
|
118
179
|
return new Promise((resolve, reject)=>{
|
|
119
|
-
const childProcess = node_child_process.exec(`${
|
|
180
|
+
const childProcess = node_child_process.exec(`${command} ${stringifyObjectArgs(ctx.args || {})}`, {
|
|
120
181
|
env: {
|
|
121
182
|
PATH: process.env.PATH,
|
|
122
183
|
...ctx.envFromProcess ? process.env : {},
|
|
123
|
-
...ctx.env
|
|
184
|
+
...ctx.env ? ctx.env : {}
|
|
124
185
|
}
|
|
125
186
|
});
|
|
126
187
|
childProcess.on('error', (data)=>{
|
|
@@ -166,247 +227,207 @@ function findModulePath(module) {
|
|
|
166
227
|
return modulePath;
|
|
167
228
|
}
|
|
168
229
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const env = ctx.env || {};
|
|
185
|
-
const data = ctx.container.getData('client/web');
|
|
186
|
-
const config = clientWebConfig.buildConfig({
|
|
187
|
-
data,
|
|
188
|
-
env: true
|
|
189
|
-
});
|
|
190
|
-
if (config.host) {
|
|
191
|
-
env.HOST = config.host;
|
|
192
|
-
}
|
|
193
|
-
if (config.port) {
|
|
194
|
-
env.PORT = `${config.port}`;
|
|
195
|
-
}
|
|
196
|
-
let command;
|
|
197
|
-
const modulePath = findModulePath(ServicePackageName.CLIENT_WEB);
|
|
198
|
-
if (typeof modulePath === 'string') {
|
|
199
|
-
const directory = path.dirname(modulePath);
|
|
200
|
-
const outputPath = path.join(directory, '.output', 'server', 'index.mjs');
|
|
201
|
-
command = `node ${outputPath}`;
|
|
202
|
-
} else {
|
|
203
|
-
command = `npx ${ServicePackageName.CLIENT_WEB}`;
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
...ctx,
|
|
207
|
-
command,
|
|
208
|
-
env: extendEnv(env)
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
async function buildServerCoreConfig(container) {
|
|
213
|
-
const data = serverCore.parseConfig(container.getData('server/core'));
|
|
214
|
-
return serverCore.buildConfig({
|
|
215
|
-
data,
|
|
216
|
-
env: true
|
|
217
|
-
});
|
|
218
|
-
}
|
|
230
|
+
/*
|
|
231
|
+
* Copyright (c) 2023.
|
|
232
|
+
* Author Peter Placzek (tada5hi)
|
|
233
|
+
* For the full copyright and license information,
|
|
234
|
+
* view the LICENSE file that was distributed with this source code.
|
|
235
|
+
*/ var PackageName = /*#__PURE__*/ function(PackageName) {
|
|
236
|
+
PackageName["CLIENT_WEB"] = "@authup/client-web";
|
|
237
|
+
PackageName["SERVER_CORE"] = "@authup/server-core";
|
|
238
|
+
return PackageName;
|
|
239
|
+
}({});
|
|
240
|
+
var PackageID = /*#__PURE__*/ function(PackageID) {
|
|
241
|
+
PackageID["CLIENT_WEB"] = "client.web";
|
|
242
|
+
PackageID["SERVER_CORE"] = "server.core";
|
|
243
|
+
return PackageID;
|
|
244
|
+
}({});
|
|
219
245
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
{
|
|
233
|
-
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
case ServiceCommand.CLEANUP:
|
|
237
|
-
{
|
|
238
|
-
command += ' reset';
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
default:
|
|
242
|
-
{
|
|
243
|
-
throw new Error(`The command ${ctx.command} is not supported.`);
|
|
246
|
+
class ClientWebPackage {
|
|
247
|
+
async execute(command, options = {}) {
|
|
248
|
+
const shellCommand = await this.buildShellCommand();
|
|
249
|
+
const env = await this.buildEnv({
|
|
250
|
+
configDirectory: options.configDirectory,
|
|
251
|
+
configFile: options.configFile
|
|
252
|
+
});
|
|
253
|
+
return execShellCommand(shellCommand, {
|
|
254
|
+
env,
|
|
255
|
+
logDataStream (line) {
|
|
256
|
+
consola.info(`${PackageID.CLIENT_WEB}: ${line}`);
|
|
257
|
+
},
|
|
258
|
+
logErrorStream (line) {
|
|
259
|
+
consola.warn(`${PackageID.CLIENT_WEB}: ${line}`);
|
|
244
260
|
}
|
|
245
|
-
}
|
|
246
|
-
return {
|
|
247
|
-
...ctx,
|
|
248
|
-
command
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function buildInfoCommand(cac) {
|
|
253
|
-
cac.command('info', 'Get information about the configuration.').option('-c, --config [config]', 'Specify a configuration file').action(async (ctx)=>{
|
|
254
|
-
const container = new config.Container({
|
|
255
|
-
prefix: 'authup',
|
|
256
|
-
keys: [
|
|
257
|
-
'client/web',
|
|
258
|
-
'server/core'
|
|
259
|
-
]
|
|
260
261
|
});
|
|
261
|
-
|
|
262
|
-
|
|
262
|
+
}
|
|
263
|
+
async buildShellCommand() {
|
|
264
|
+
let shellCommand;
|
|
265
|
+
const modulePath = findModulePath(PackageName.CLIENT_WEB);
|
|
266
|
+
if (typeof modulePath === 'string') {
|
|
267
|
+
const directory = path.dirname(modulePath);
|
|
268
|
+
const outputPath = path.join(directory, '.output', 'server', 'index.mjs');
|
|
269
|
+
shellCommand = `node ${outputPath}`;
|
|
263
270
|
} else {
|
|
264
|
-
|
|
271
|
+
shellCommand = `npx ${PackageName.CLIENT_WEB}`;
|
|
265
272
|
}
|
|
266
|
-
|
|
267
|
-
consola.info(`Host: ${clientWeb.host}`);
|
|
268
|
-
consola.info(`Port: ${clientWeb.port}`);
|
|
269
|
-
consola.info('------------');
|
|
270
|
-
const serverCore = await buildServerCoreConfig(container);
|
|
271
|
-
consola.info(`Host: ${serverCore.host}`);
|
|
272
|
-
consola.info(`Port: ${serverCore.port}`);
|
|
273
|
-
consola.info(`Environment: ${serverCore.env}`);
|
|
274
|
-
consola.info(`RootPath: ${serverCore.rootPath}`);
|
|
275
|
-
consola.info(`WritableDirectoryPath: ${serverCore.writableDirectoryPath}`);
|
|
276
|
-
consola.info('------------');
|
|
277
|
-
consola.info('Report an issue: https://github.com/authup/authup/issues/new');
|
|
278
|
-
consola.info('Suggest an improvement: https://github.com/authup/authup/discussions/new');
|
|
279
|
-
consola.info('Read documentation: https://authup.org');
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
async function executeServiceCommand(context) {
|
|
284
|
-
let service;
|
|
285
|
-
if (typeof context.service === 'string') {
|
|
286
|
-
service = config.deserializeKey(context.service);
|
|
287
|
-
} else {
|
|
288
|
-
service = context.service;
|
|
273
|
+
return shellCommand;
|
|
289
274
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
275
|
+
async buildEnv(ctx) {
|
|
276
|
+
const env = {};
|
|
277
|
+
const configRaw = await readClientWebConfigRaw({
|
|
278
|
+
fs: {
|
|
279
|
+
file: ctx.configFile,
|
|
280
|
+
cwd: ctx.configDirectory
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
const config = buildClientWebConfig(configRaw);
|
|
284
|
+
if (config.host) {
|
|
285
|
+
env.HOST = config.host;
|
|
296
286
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
try {
|
|
300
|
-
if (service.group === 'server' && service.name === 'core') {
|
|
301
|
-
shellExecContext = buildServerCoreExecutionContext({
|
|
302
|
-
command: context.command,
|
|
303
|
-
env
|
|
304
|
-
});
|
|
287
|
+
if (config.port) {
|
|
288
|
+
env.PORT = `${config.port}`;
|
|
305
289
|
}
|
|
306
|
-
if (
|
|
307
|
-
|
|
308
|
-
container: context.container,
|
|
309
|
-
command: context.command,
|
|
310
|
-
env
|
|
311
|
-
});
|
|
290
|
+
if (config.apiUrl) {
|
|
291
|
+
env.API_URL = config.apiUrl;
|
|
312
292
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (!shellExecContext) {
|
|
318
|
-
consola.error(`${service.group}/${service.name}: The service is not supported.`);
|
|
319
|
-
process.exit(1);
|
|
293
|
+
if (config.publicUrl) {
|
|
294
|
+
env.PUBLIC_URL = config.publicUrl;
|
|
295
|
+
}
|
|
296
|
+
return this.extendEnvKeys(env);
|
|
320
297
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
298
|
+
extendEnvKeys(input) {
|
|
299
|
+
const env = {};
|
|
300
|
+
const keys = Object.keys(input);
|
|
301
|
+
for(let i = 0; i < keys.length; i++){
|
|
302
|
+
env[keys[i]] = input[keys[i]];
|
|
303
|
+
if (!keys[i].match(/^(?:NUXT|NITRO)_.*$/)) {
|
|
304
|
+
env[`NUXT_PUBLIC_${keys[i]}`] = input[keys[i]];
|
|
305
|
+
}
|
|
328
306
|
}
|
|
329
|
-
|
|
307
|
+
return env;
|
|
308
|
+
}
|
|
330
309
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
310
|
+
|
|
311
|
+
class ServerCorePackage {
|
|
312
|
+
async execute(command, options = {}) {
|
|
313
|
+
const shellCommand = await this.buildShellCommand(command, {
|
|
314
|
+
configDirectory: options.configDirectory,
|
|
315
|
+
configFile: options.configFile
|
|
316
|
+
});
|
|
317
|
+
return execShellCommand(shellCommand, {
|
|
318
|
+
logDataStream (line) {
|
|
319
|
+
consola.info(`${PackageID.SERVER_CORE}: ${line}`);
|
|
320
|
+
},
|
|
321
|
+
logErrorStream (line) {
|
|
322
|
+
consola.warn(`${PackageID.SERVER_CORE}: ${line}`);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
340
325
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
|
|
346
|
-
|
|
326
|
+
async buildShellCommand(command, options) {
|
|
327
|
+
const parts = [];
|
|
328
|
+
const modulePath = findModulePath(PackageName.SERVER_CORE);
|
|
329
|
+
if (typeof modulePath === 'string') {
|
|
330
|
+
const directory = path.dirname(modulePath);
|
|
331
|
+
const outputPath = path.join(directory, 'dist', 'cli', 'index.js');
|
|
332
|
+
parts.push(`node ${outputPath}`);
|
|
333
|
+
} else {
|
|
334
|
+
parts.push(`npx ${PackageName.SERVER_CORE}`);
|
|
347
335
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
336
|
+
parts.push(command);
|
|
337
|
+
if (options.configFile) {
|
|
338
|
+
parts.push(`--configFile=${options.configFile}`);
|
|
351
339
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
service,
|
|
355
|
-
container
|
|
356
|
-
}));
|
|
357
|
-
}
|
|
358
|
-
const childProcesses = await Promise.all(promises);
|
|
359
|
-
const readLine = readline.createInterface({
|
|
360
|
-
input: process.stdin,
|
|
361
|
-
output: process.stdout
|
|
362
|
-
});
|
|
363
|
-
readLine.on('SIGINT', ()=>{
|
|
364
|
-
for(let i = 0; i < childProcesses.length; i++){
|
|
365
|
-
childProcesses[i].kill();
|
|
340
|
+
if (options.configDirectory) {
|
|
341
|
+
parts.push(`--configDirectory=${options.configDirectory}`);
|
|
366
342
|
}
|
|
367
|
-
|
|
368
|
-
}
|
|
343
|
+
return parts.join(' ');
|
|
344
|
+
}
|
|
369
345
|
}
|
|
370
346
|
|
|
371
|
-
function
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
});
|
|
347
|
+
async function executePackageCommand(pkg, command, options = {}) {
|
|
348
|
+
switch(pkg){
|
|
349
|
+
case PackageID.CLIENT_WEB:
|
|
350
|
+
{
|
|
351
|
+
const serverCore = new ClientWebPackage();
|
|
352
|
+
return serverCore.execute(command, options);
|
|
353
|
+
}
|
|
354
|
+
case PackageID.SERVER_CORE:
|
|
355
|
+
{
|
|
356
|
+
const serverCore = new ServerCorePackage();
|
|
357
|
+
return serverCore.execute(command, options);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
throw new Error(`The package ${pkg} is not supported.`);
|
|
386
361
|
}
|
|
387
362
|
|
|
388
|
-
function
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
363
|
+
function normalizePackageID(input) {
|
|
364
|
+
const value = input.trim().toLowerCase();
|
|
365
|
+
switch(value){
|
|
366
|
+
case 'client.web':
|
|
367
|
+
case 'client/web':
|
|
368
|
+
case 'client-web':
|
|
369
|
+
{
|
|
370
|
+
return PackageID.CLIENT_WEB;
|
|
371
|
+
}
|
|
372
|
+
case 'server.core':
|
|
373
|
+
case 'server/core':
|
|
374
|
+
case 'server-core':
|
|
375
|
+
{
|
|
376
|
+
return PackageID.SERVER_CORE;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return undefined;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
async function createCLIEntryPointCommand() {
|
|
383
|
+
const pkgRaw = await fs.promises.readFile(path.join(process.cwd(), 'package.json'), {
|
|
384
|
+
encoding: 'utf8'
|
|
385
|
+
});
|
|
386
|
+
const pkg = JSON.parse(pkgRaw);
|
|
387
|
+
return citty.defineCommand({
|
|
388
|
+
meta: {
|
|
389
|
+
name: pkg.name,
|
|
390
|
+
version: pkg.version,
|
|
391
|
+
description: pkg.description
|
|
392
|
+
},
|
|
393
|
+
args: {
|
|
394
|
+
command: {
|
|
395
|
+
type: 'positional',
|
|
396
|
+
description: 'The command which should be forwarded to the package.'
|
|
397
|
+
},
|
|
398
|
+
package: {
|
|
399
|
+
type: 'positional',
|
|
400
|
+
description: 'The package, which should be targeted.',
|
|
401
|
+
required: false
|
|
402
|
+
},
|
|
403
|
+
configDirectory: {
|
|
404
|
+
type: 'string',
|
|
405
|
+
description: 'Config directory path',
|
|
406
|
+
alias: 'cD'
|
|
407
|
+
},
|
|
408
|
+
configFile: {
|
|
409
|
+
type: 'string',
|
|
410
|
+
description: 'Name of one or more configuration files.',
|
|
411
|
+
alias: 'cF'
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
async run (ctx) {
|
|
415
|
+
let pkgs = ctx.args.package ? ctx.args.package.split(',') : [];
|
|
416
|
+
pkgs = pkgs.map((pkg)=>normalizePackageID(pkg)).filter((pkg)=>Boolean(pkg));
|
|
417
|
+
if (pkgs.length === 0) {
|
|
418
|
+
pkgs = Object.values(PackageID);
|
|
419
|
+
}
|
|
420
|
+
const promises = [];
|
|
421
|
+
for(let i = 0; i < pkgs.length; i++){
|
|
422
|
+
promises.push(executePackageCommand(pkgs[i], ctx.args.command, {
|
|
423
|
+
configFile: ctx.args.configFile,
|
|
424
|
+
configDirectory: ctx.args.configDirectory
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
|
+
await Promise.all(promises);
|
|
396
428
|
}
|
|
397
|
-
await executeServicesCommand({
|
|
398
|
-
config: ctx.config,
|
|
399
|
-
command: ServiceCommand.START,
|
|
400
|
-
services: keysInput,
|
|
401
|
-
servicesAllowed
|
|
402
|
-
});
|
|
403
429
|
});
|
|
404
430
|
}
|
|
405
431
|
|
|
406
|
-
|
|
407
|
-
buildInfoCommand(cli);
|
|
408
|
-
buildStartCommand(cli);
|
|
409
|
-
buildCleanupCommand(cli);
|
|
410
|
-
cli.help();
|
|
411
|
-
cli.parse();
|
|
432
|
+
Promise.resolve().then(()=>createCLIEntryPointCommand()).then((command)=>citty.runMain(command));
|
|
412
433
|
//# sourceMappingURL=index.cjs.map
|