@akanjs/devkit 0.0.85 → 0.0.87
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/package.json +3 -2
- package/src/createTunnel.cjs +12 -4
- package/src/createTunnel.d.ts +3 -2
- package/src/createTunnel.js +12 -4
- package/src/executors.cjs +32 -12
- package/src/executors.d.ts +11 -2
- package/src/executors.js +32 -12
- package/src/index.cjs +0 -2
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/baseDevEnv.cjs +0 -50
- package/src/baseDevEnv.d.ts +0 -10
- package/src/baseDevEnv.js +0 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/devkit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.87",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"@trapezedev/project": "^7.1.3",
|
|
22
22
|
"axios": "^1.7.9",
|
|
23
23
|
"commander": "^13.1.0",
|
|
24
|
+
"dotenv": "^16.4.7",
|
|
24
25
|
"form-data": "^4.0.1",
|
|
25
26
|
"js-yaml": "^4.1.0",
|
|
26
27
|
"ora": "^3.4.0",
|
|
@@ -34,4 +35,4 @@
|
|
|
34
35
|
"import": "./index.js"
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
}
|
|
38
|
+
}
|
package/src/createTunnel.cjs
CHANGED
|
@@ -21,15 +21,23 @@ __export(createTunnel_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(createTunnel_exports);
|
|
23
23
|
var import_tunnel_ssh = require("tunnel-ssh");
|
|
24
|
-
|
|
25
|
-
const
|
|
24
|
+
const getSshTunnelOptions = (app, environment) => {
|
|
25
|
+
const { serveDomain, repoName } = app.workspace.getBaseDevEnv();
|
|
26
|
+
return {
|
|
27
|
+
host: `${app.name}-${environment}.${serveDomain}`,
|
|
28
|
+
port: process.env.SSH_TUNNEL_PORT ? parseInt(process.env.SSH_TUNNEL_PORT) : 32767,
|
|
29
|
+
username: process.env.SSH_TUNNEL_USERNAME ?? "root",
|
|
30
|
+
password: process.env.SSH_TUNNEL_PASSWORD ?? repoName
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const createTunnel = async ({ app, environment, port = 27017 }) => {
|
|
26
34
|
const tunnelOptions = { autoClose: true, reconnectOnError: true };
|
|
27
|
-
const sshOptions =
|
|
35
|
+
const sshOptions = getSshTunnelOptions(app, environment);
|
|
28
36
|
const serverOptions = { port };
|
|
29
37
|
const forwardOptions = {
|
|
30
38
|
srcAddr: "0.0.0.0",
|
|
31
39
|
srcPort: port,
|
|
32
|
-
dstAddr: `mongo-0.mongo-svc.${
|
|
40
|
+
dstAddr: `mongo-0.mongo-svc.${app.name}-${environment}`,
|
|
33
41
|
dstPort: 27017
|
|
34
42
|
};
|
|
35
43
|
const [server, client] = await (0, import_tunnel_ssh.createTunnel)(tunnelOptions, serverOptions, sshOptions, forwardOptions);
|
package/src/createTunnel.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { AppExecutor } from "./executors";
|
|
1
2
|
interface TunnelOption {
|
|
2
|
-
|
|
3
|
+
app: AppExecutor;
|
|
3
4
|
environment: string;
|
|
4
5
|
port?: number;
|
|
5
6
|
}
|
|
6
|
-
export declare const createTunnel: ({
|
|
7
|
+
export declare const createTunnel: ({ app, environment, port }: TunnelOption) => Promise<string>;
|
|
7
8
|
export {};
|
package/src/createTunnel.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { createTunnel as create } from "tunnel-ssh";
|
|
2
|
-
|
|
3
|
-
const
|
|
2
|
+
const getSshTunnelOptions = (app, environment) => {
|
|
3
|
+
const { serveDomain, repoName } = app.workspace.getBaseDevEnv();
|
|
4
|
+
return {
|
|
5
|
+
host: `${app.name}-${environment}.${serveDomain}`,
|
|
6
|
+
port: process.env.SSH_TUNNEL_PORT ? parseInt(process.env.SSH_TUNNEL_PORT) : 32767,
|
|
7
|
+
username: process.env.SSH_TUNNEL_USERNAME ?? "root",
|
|
8
|
+
password: process.env.SSH_TUNNEL_PASSWORD ?? repoName
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const createTunnel = async ({ app, environment, port = 27017 }) => {
|
|
4
12
|
const tunnelOptions = { autoClose: true, reconnectOnError: true };
|
|
5
|
-
const sshOptions = getSshTunnelOptions(
|
|
13
|
+
const sshOptions = getSshTunnelOptions(app, environment);
|
|
6
14
|
const serverOptions = { port };
|
|
7
15
|
const forwardOptions = {
|
|
8
16
|
srcAddr: "0.0.0.0",
|
|
9
17
|
srcPort: port,
|
|
10
|
-
dstAddr: `mongo-0.mongo-svc.${
|
|
18
|
+
dstAddr: `mongo-0.mongo-svc.${app.name}-${environment}`,
|
|
11
19
|
dstPort: 27017
|
|
12
20
|
};
|
|
13
21
|
const [server, client] = await create(tunnelOptions, serverOptions, sshOptions, forwardOptions);
|
package/src/executors.cjs
CHANGED
|
@@ -44,7 +44,7 @@ var import_child_process = require("child_process");
|
|
|
44
44
|
var import_fs = __toESM(require("fs"), 1);
|
|
45
45
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
46
46
|
var import_path = __toESM(require("path"), 1);
|
|
47
|
-
var
|
|
47
|
+
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
48
48
|
var import_dependencyScanner = require("./dependencyScanner");
|
|
49
49
|
class Executor {
|
|
50
50
|
logger;
|
|
@@ -121,7 +121,7 @@ class Executor {
|
|
|
121
121
|
const readPath = this.#getPath(filePath);
|
|
122
122
|
return import_fs.default.existsSync(readPath);
|
|
123
123
|
}
|
|
124
|
-
writeFile(filePath, content) {
|
|
124
|
+
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
125
125
|
const writePath = this.#getPath(filePath);
|
|
126
126
|
const dir = import_path.default.dirname(writePath);
|
|
127
127
|
if (!import_fs.default.existsSync(dir))
|
|
@@ -129,7 +129,7 @@ class Executor {
|
|
|
129
129
|
const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
130
130
|
if (import_fs.default.existsSync(writePath)) {
|
|
131
131
|
const currentContent = import_fs.default.readFileSync(writePath, "utf8");
|
|
132
|
-
if (currentContent === contentStr)
|
|
132
|
+
if (currentContent === contentStr || !overwrite)
|
|
133
133
|
this.logger.verbose(`File ${writePath} is unchanged`);
|
|
134
134
|
else {
|
|
135
135
|
import_fs.default.writeFileSync(writePath, contentStr, "utf8");
|
|
@@ -142,7 +142,7 @@ class Executor {
|
|
|
142
142
|
return this;
|
|
143
143
|
}
|
|
144
144
|
writeJson(filePath, content) {
|
|
145
|
-
this.writeFile(filePath, JSON.stringify(content, null, 2));
|
|
145
|
+
this.writeFile(filePath, JSON.stringify(content, null, 2) + "\n");
|
|
146
146
|
return this;
|
|
147
147
|
}
|
|
148
148
|
getLocalFile(filePath) {
|
|
@@ -186,7 +186,8 @@ class Executor {
|
|
|
186
186
|
async #applyTemplateFile({
|
|
187
187
|
templatePath,
|
|
188
188
|
targetPath,
|
|
189
|
-
scanResult
|
|
189
|
+
scanResult,
|
|
190
|
+
overwrite = true
|
|
190
191
|
}, dict = {}) {
|
|
191
192
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
192
193
|
const getContent = await import(templatePath);
|
|
@@ -220,12 +221,16 @@ class Executor {
|
|
|
220
221
|
basePath,
|
|
221
222
|
template,
|
|
222
223
|
scanResult,
|
|
223
|
-
dict = {}
|
|
224
|
+
dict = {},
|
|
225
|
+
overwrite = true
|
|
224
226
|
}) {
|
|
225
227
|
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
226
228
|
if (import_fs.default.statSync(templatePath).isFile()) {
|
|
227
229
|
const filename = import_path.default.basename(templatePath);
|
|
228
|
-
await this.#applyTemplateFile(
|
|
230
|
+
await this.#applyTemplateFile(
|
|
231
|
+
{ templatePath, targetPath: import_path.default.join(basePath, filename), scanResult, overwrite },
|
|
232
|
+
dict
|
|
233
|
+
);
|
|
229
234
|
} else {
|
|
230
235
|
const subdirs = await import_promises.default.readdir(templatePath);
|
|
231
236
|
await Promise.all(
|
|
@@ -233,7 +238,7 @@ class Executor {
|
|
|
233
238
|
const subpath = import_path.default.join(templatePath, subdir);
|
|
234
239
|
if (import_fs.default.statSync(subpath).isFile())
|
|
235
240
|
await this.#applyTemplateFile(
|
|
236
|
-
{ templatePath: subpath, targetPath: import_path.default.join(basePath, subdir), scanResult },
|
|
241
|
+
{ templatePath: subpath, targetPath: import_path.default.join(basePath, subdir), scanResult, overwrite },
|
|
237
242
|
dict
|
|
238
243
|
);
|
|
239
244
|
else
|
|
@@ -241,7 +246,8 @@ class Executor {
|
|
|
241
246
|
basePath: import_path.default.join(basePath, subdir),
|
|
242
247
|
template: import_path.default.join(template, subdir),
|
|
243
248
|
scanResult,
|
|
244
|
-
dict
|
|
249
|
+
dict,
|
|
250
|
+
overwrite
|
|
245
251
|
});
|
|
246
252
|
})
|
|
247
253
|
);
|
|
@@ -260,6 +266,20 @@ class WorkspaceExecutor extends Executor {
|
|
|
260
266
|
const repoName = import_path.default.basename(process.cwd());
|
|
261
267
|
return new WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
|
|
262
268
|
}
|
|
269
|
+
getBaseDevEnv() {
|
|
270
|
+
const envFile = import_dotenv.default.parse(this.readFile(".env"));
|
|
271
|
+
const appName = process.env.NEXT_PUBLIC_APP_NAME ?? envFile.NEXT_PUBLIC_APP_NAME;
|
|
272
|
+
const repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? envFile.NEXT_PUBLIC_REPO_NAME;
|
|
273
|
+
if (!repoName)
|
|
274
|
+
throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
|
|
275
|
+
const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? envFile.NEXT_PUBLIC_SERVE_DOMAIN;
|
|
276
|
+
if (!serveDomain)
|
|
277
|
+
throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
|
|
278
|
+
const env = process.env.NEXT_PUBLIC_ENV ?? envFile.NEXT_PUBLIC_ENV ?? "debug";
|
|
279
|
+
if (!env)
|
|
280
|
+
throw new Error("NEXT_PUBLIC_ENV is not set");
|
|
281
|
+
return { ...appName ? { appName } : {}, repoName, serveDomain, env };
|
|
282
|
+
}
|
|
263
283
|
async scan() {
|
|
264
284
|
const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
|
|
265
285
|
const [appScanResults, libScanResults, pkgScanResults] = await Promise.all([
|
|
@@ -362,7 +382,7 @@ class SysExecutor extends Executor {
|
|
|
362
382
|
this.type = type;
|
|
363
383
|
}
|
|
364
384
|
async getConfig(command) {
|
|
365
|
-
return this.type === "app" ? await (0, import_config.getAppConfig)(this.cwdPath, { ...
|
|
385
|
+
return this.type === "app" ? await (0, import_config.getAppConfig)(this.cwdPath, { ...this.workspace.getBaseDevEnv(), appName: this.name, command }) : await (0, import_config.getLibConfig)(this.cwdPath, { ...this.workspace.getBaseDevEnv(), appName: this.name, command });
|
|
366
386
|
}
|
|
367
387
|
async scan({
|
|
368
388
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
|
|
@@ -560,7 +580,7 @@ class AppExecutor extends SysExecutor {
|
|
|
560
580
|
return new AppExecutor({ workspace: executor.workspace, name });
|
|
561
581
|
}
|
|
562
582
|
async getConfig(command) {
|
|
563
|
-
return await (0, import_config.getAppConfig)(this.cwdPath, { ...
|
|
583
|
+
return await (0, import_config.getAppConfig)(this.cwdPath, { ...this.workspace.getBaseDevEnv(), appName: this.name, command });
|
|
564
584
|
}
|
|
565
585
|
async syncAssets(libDeps) {
|
|
566
586
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
@@ -601,7 +621,7 @@ class LibExecutor extends SysExecutor {
|
|
|
601
621
|
return new LibExecutor({ workspace: executor.workspace, name });
|
|
602
622
|
}
|
|
603
623
|
async getConfig(command) {
|
|
604
|
-
return await (0, import_config.getLibConfig)(this.cwdPath, { ...
|
|
624
|
+
return await (0, import_config.getLibConfig)(this.cwdPath, { ...this.workspace.getBaseDevEnv(), appName: this.name, command });
|
|
605
625
|
}
|
|
606
626
|
}
|
|
607
627
|
class DistLibExecutor extends Executor {
|
package/src/executors.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ export declare class Executor {
|
|
|
15
15
|
fork(modulePath: string, args?: string[], options?: ForkOptions): Promise<unknown>;
|
|
16
16
|
mkdir(dirPath: string): this;
|
|
17
17
|
exists(filePath: string): boolean;
|
|
18
|
-
writeFile(filePath: string, content: string | object
|
|
18
|
+
writeFile(filePath: string, content: string | object, { overwrite }?: {
|
|
19
|
+
overwrite?: boolean;
|
|
20
|
+
}): this;
|
|
19
21
|
writeJson(filePath: string, content: object): this;
|
|
20
22
|
getLocalFile(filePath: string): {
|
|
21
23
|
filepath: string;
|
|
@@ -27,13 +29,14 @@ export declare class Executor {
|
|
|
27
29
|
log(msg: string): this;
|
|
28
30
|
verbose(msg: string): this;
|
|
29
31
|
getTsConfig(pathname: string): TsConfigJson;
|
|
30
|
-
applyTemplate({ basePath, template, scanResult, dict, }: {
|
|
32
|
+
applyTemplate({ basePath, template, scanResult, dict, overwrite, }: {
|
|
31
33
|
basePath: string;
|
|
32
34
|
template: string;
|
|
33
35
|
scanResult?: AppScanResult | LibScanResult | null;
|
|
34
36
|
dict?: {
|
|
35
37
|
[key: string]: string;
|
|
36
38
|
};
|
|
39
|
+
overwrite?: boolean;
|
|
37
40
|
}): Promise<void>;
|
|
38
41
|
}
|
|
39
42
|
interface ExecutorOptions {
|
|
@@ -46,6 +49,12 @@ export declare class WorkspaceExecutor extends Executor {
|
|
|
46
49
|
repoName: string;
|
|
47
50
|
constructor({ workspaceRoot, repoName }: ExecutorOptions);
|
|
48
51
|
static fromRoot(): WorkspaceExecutor;
|
|
52
|
+
getBaseDevEnv(): {
|
|
53
|
+
repoName: string;
|
|
54
|
+
serveDomain: string;
|
|
55
|
+
env: "debug" | "testing" | "develop" | "main";
|
|
56
|
+
appName?: string | undefined;
|
|
57
|
+
};
|
|
49
58
|
scan(): Promise<WorkspaceScanResult>;
|
|
50
59
|
getApps(): Promise<string[]>;
|
|
51
60
|
getLibs(): Promise<string[]>;
|
package/src/executors.js
CHANGED
|
@@ -8,7 +8,7 @@ import { exec, fork, spawn } from "child_process";
|
|
|
8
8
|
import fs from "fs";
|
|
9
9
|
import fsPromise from "fs/promises";
|
|
10
10
|
import path from "path";
|
|
11
|
-
import
|
|
11
|
+
import dotenv from "dotenv";
|
|
12
12
|
import { TypeScriptDependencyScanner } from "./dependencyScanner";
|
|
13
13
|
class Executor {
|
|
14
14
|
logger;
|
|
@@ -85,7 +85,7 @@ class Executor {
|
|
|
85
85
|
const readPath = this.#getPath(filePath);
|
|
86
86
|
return fs.existsSync(readPath);
|
|
87
87
|
}
|
|
88
|
-
writeFile(filePath, content) {
|
|
88
|
+
writeFile(filePath, content, { overwrite = true } = {}) {
|
|
89
89
|
const writePath = this.#getPath(filePath);
|
|
90
90
|
const dir = path.dirname(writePath);
|
|
91
91
|
if (!fs.existsSync(dir))
|
|
@@ -93,7 +93,7 @@ class Executor {
|
|
|
93
93
|
const contentStr = typeof content === "string" ? content : JSON.stringify(content, null, 2);
|
|
94
94
|
if (fs.existsSync(writePath)) {
|
|
95
95
|
const currentContent = fs.readFileSync(writePath, "utf8");
|
|
96
|
-
if (currentContent === contentStr)
|
|
96
|
+
if (currentContent === contentStr || !overwrite)
|
|
97
97
|
this.logger.verbose(`File ${writePath} is unchanged`);
|
|
98
98
|
else {
|
|
99
99
|
fs.writeFileSync(writePath, contentStr, "utf8");
|
|
@@ -106,7 +106,7 @@ class Executor {
|
|
|
106
106
|
return this;
|
|
107
107
|
}
|
|
108
108
|
writeJson(filePath, content) {
|
|
109
|
-
this.writeFile(filePath, JSON.stringify(content, null, 2));
|
|
109
|
+
this.writeFile(filePath, JSON.stringify(content, null, 2) + "\n");
|
|
110
110
|
return this;
|
|
111
111
|
}
|
|
112
112
|
getLocalFile(filePath) {
|
|
@@ -150,7 +150,8 @@ class Executor {
|
|
|
150
150
|
async #applyTemplateFile({
|
|
151
151
|
templatePath,
|
|
152
152
|
targetPath,
|
|
153
|
-
scanResult
|
|
153
|
+
scanResult,
|
|
154
|
+
overwrite = true
|
|
154
155
|
}, dict = {}) {
|
|
155
156
|
if (targetPath.endsWith(".js") || targetPath.endsWith(".jsx")) {
|
|
156
157
|
const getContent = await import(templatePath);
|
|
@@ -184,12 +185,16 @@ class Executor {
|
|
|
184
185
|
basePath,
|
|
185
186
|
template,
|
|
186
187
|
scanResult,
|
|
187
|
-
dict = {}
|
|
188
|
+
dict = {},
|
|
189
|
+
overwrite = true
|
|
188
190
|
}) {
|
|
189
191
|
const templatePath = `${__dirname}/src/templates${template ? `/${template}` : ""}`.replace(".ts", ".js");
|
|
190
192
|
if (fs.statSync(templatePath).isFile()) {
|
|
191
193
|
const filename = path.basename(templatePath);
|
|
192
|
-
await this.#applyTemplateFile(
|
|
194
|
+
await this.#applyTemplateFile(
|
|
195
|
+
{ templatePath, targetPath: path.join(basePath, filename), scanResult, overwrite },
|
|
196
|
+
dict
|
|
197
|
+
);
|
|
193
198
|
} else {
|
|
194
199
|
const subdirs = await fsPromise.readdir(templatePath);
|
|
195
200
|
await Promise.all(
|
|
@@ -197,7 +202,7 @@ class Executor {
|
|
|
197
202
|
const subpath = path.join(templatePath, subdir);
|
|
198
203
|
if (fs.statSync(subpath).isFile())
|
|
199
204
|
await this.#applyTemplateFile(
|
|
200
|
-
{ templatePath: subpath, targetPath: path.join(basePath, subdir), scanResult },
|
|
205
|
+
{ templatePath: subpath, targetPath: path.join(basePath, subdir), scanResult, overwrite },
|
|
201
206
|
dict
|
|
202
207
|
);
|
|
203
208
|
else
|
|
@@ -205,7 +210,8 @@ class Executor {
|
|
|
205
210
|
basePath: path.join(basePath, subdir),
|
|
206
211
|
template: path.join(template, subdir),
|
|
207
212
|
scanResult,
|
|
208
|
-
dict
|
|
213
|
+
dict,
|
|
214
|
+
overwrite
|
|
209
215
|
});
|
|
210
216
|
})
|
|
211
217
|
);
|
|
@@ -224,6 +230,20 @@ class WorkspaceExecutor extends Executor {
|
|
|
224
230
|
const repoName = path.basename(process.cwd());
|
|
225
231
|
return new WorkspaceExecutor({ workspaceRoot: process.cwd(), repoName });
|
|
226
232
|
}
|
|
233
|
+
getBaseDevEnv() {
|
|
234
|
+
const envFile = dotenv.parse(this.readFile(".env"));
|
|
235
|
+
const appName = process.env.NEXT_PUBLIC_APP_NAME ?? envFile.NEXT_PUBLIC_APP_NAME;
|
|
236
|
+
const repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? envFile.NEXT_PUBLIC_REPO_NAME;
|
|
237
|
+
if (!repoName)
|
|
238
|
+
throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
|
|
239
|
+
const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? envFile.NEXT_PUBLIC_SERVE_DOMAIN;
|
|
240
|
+
if (!serveDomain)
|
|
241
|
+
throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
|
|
242
|
+
const env = process.env.NEXT_PUBLIC_ENV ?? envFile.NEXT_PUBLIC_ENV ?? "debug";
|
|
243
|
+
if (!env)
|
|
244
|
+
throw new Error("NEXT_PUBLIC_ENV is not set");
|
|
245
|
+
return { ...appName ? { appName } : {}, repoName, serveDomain, env };
|
|
246
|
+
}
|
|
227
247
|
async scan() {
|
|
228
248
|
const [appNames, libNames, pkgNames] = await Promise.all([this.getApps(), this.getLibs(), this.getPkgs()]);
|
|
229
249
|
const [appScanResults, libScanResults, pkgScanResults] = await Promise.all([
|
|
@@ -326,7 +346,7 @@ class SysExecutor extends Executor {
|
|
|
326
346
|
this.type = type;
|
|
327
347
|
}
|
|
328
348
|
async getConfig(command) {
|
|
329
|
-
return this.type === "app" ? await getAppConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command }) : await getLibConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
|
|
349
|
+
return this.type === "app" ? await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), appName: this.name, command }) : await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), appName: this.name, command });
|
|
330
350
|
}
|
|
331
351
|
async scan({
|
|
332
352
|
tsconfig = this.getTsConfig(`${this.cwdPath}/tsconfig.json`),
|
|
@@ -524,7 +544,7 @@ class AppExecutor extends SysExecutor {
|
|
|
524
544
|
return new AppExecutor({ workspace: executor.workspace, name });
|
|
525
545
|
}
|
|
526
546
|
async getConfig(command) {
|
|
527
|
-
return await getAppConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
|
|
547
|
+
return await getAppConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), appName: this.name, command });
|
|
528
548
|
}
|
|
529
549
|
async syncAssets(libDeps) {
|
|
530
550
|
const projectPublicLibPath = `${this.cwdPath}/public/libs`;
|
|
@@ -565,7 +585,7 @@ class LibExecutor extends SysExecutor {
|
|
|
565
585
|
return new LibExecutor({ workspace: executor.workspace, name });
|
|
566
586
|
}
|
|
567
587
|
async getConfig(command) {
|
|
568
|
-
return await getLibConfig(this.cwdPath, { ...getBaseDevEnv(), appName: this.name, command });
|
|
588
|
+
return await getLibConfig(this.cwdPath, { ...this.workspace.getBaseDevEnv(), appName: this.name, command });
|
|
569
589
|
}
|
|
570
590
|
}
|
|
571
591
|
class DistLibExecutor extends Executor {
|
package/src/index.cjs
CHANGED
|
@@ -14,7 +14,6 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var src_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(src_exports);
|
|
17
|
-
__reExport(src_exports, require("./baseDevEnv"), module.exports);
|
|
18
17
|
__reExport(src_exports, require("./createTunnel"), module.exports);
|
|
19
18
|
__reExport(src_exports, require("./getCredentials"), module.exports);
|
|
20
19
|
__reExport(src_exports, require("./uploadRelease"), module.exports);
|
|
@@ -34,7 +33,6 @@ __reExport(src_exports, require("./installExternalLib"), module.exports);
|
|
|
34
33
|
__reExport(src_exports, require("./aiEditor"), module.exports);
|
|
35
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
35
|
0 && (module.exports = {
|
|
37
|
-
...require("./baseDevEnv"),
|
|
38
36
|
...require("./createTunnel"),
|
|
39
37
|
...require("./getCredentials"),
|
|
40
38
|
...require("./uploadRelease"),
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/baseDevEnv.cjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var baseDevEnv_exports = {};
|
|
19
|
-
__export(baseDevEnv_exports, {
|
|
20
|
-
getBaseDevEnv: () => getBaseDevEnv,
|
|
21
|
-
getSshTunnelOptions: () => getSshTunnelOptions
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(baseDevEnv_exports);
|
|
24
|
-
const getBaseDevEnv = () => {
|
|
25
|
-
const appName = process.env.NEXT_PUBLIC_APP_NAME;
|
|
26
|
-
const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
|
|
27
|
-
if (!repoName)
|
|
28
|
-
throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
|
|
29
|
-
const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
|
|
30
|
-
if (!serveDomain)
|
|
31
|
-
throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
|
|
32
|
-
const env = process.env.NEXT_PUBLIC_ENV ?? "debug";
|
|
33
|
-
if (!env)
|
|
34
|
-
throw new Error("NEXT_PUBLIC_ENV is not set");
|
|
35
|
-
return { ...appName ? { appName } : {}, repoName, serveDomain, env };
|
|
36
|
-
};
|
|
37
|
-
const getSshTunnelOptions = (appName, environment) => {
|
|
38
|
-
const { serveDomain, repoName } = getBaseDevEnv();
|
|
39
|
-
return {
|
|
40
|
-
host: `${appName}-${environment}.${serveDomain}`,
|
|
41
|
-
port: process.env.SSU_TUNNEL_PORT ? parseInt(process.env.SSU_TUNNEL_PORT) : 32767,
|
|
42
|
-
username: process.env.SSU_TUNNEL_USERNAME ?? "root",
|
|
43
|
-
password: process.env.SSU_TUNNEL_PASSWORD ?? repoName
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
getBaseDevEnv,
|
|
49
|
-
getSshTunnelOptions
|
|
50
|
-
});
|
package/src/baseDevEnv.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SshOptions } from "tunnel-ssh";
|
|
2
|
-
interface BaseDevEnv {
|
|
3
|
-
appName?: string;
|
|
4
|
-
repoName: string;
|
|
5
|
-
serveDomain: string;
|
|
6
|
-
env: "testing" | "debug" | "develop" | "main";
|
|
7
|
-
}
|
|
8
|
-
export declare const getBaseDevEnv: () => BaseDevEnv;
|
|
9
|
-
export declare const getSshTunnelOptions: (appName: string, environment: string) => SshOptions;
|
|
10
|
-
export {};
|
package/src/baseDevEnv.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const getBaseDevEnv = () => {
|
|
2
|
-
const appName = process.env.NEXT_PUBLIC_APP_NAME;
|
|
3
|
-
const repoName = process.env.NEXT_PUBLIC_REPO_NAME;
|
|
4
|
-
if (!repoName)
|
|
5
|
-
throw new Error("NEXT_PUBLIC_REPO_NAME is not set");
|
|
6
|
-
const serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN;
|
|
7
|
-
if (!serveDomain)
|
|
8
|
-
throw new Error("NEXT_PUBLIC_SERVE_DOMAIN is not set");
|
|
9
|
-
const env = process.env.NEXT_PUBLIC_ENV ?? "debug";
|
|
10
|
-
if (!env)
|
|
11
|
-
throw new Error("NEXT_PUBLIC_ENV is not set");
|
|
12
|
-
return { ...appName ? { appName } : {}, repoName, serveDomain, env };
|
|
13
|
-
};
|
|
14
|
-
const getSshTunnelOptions = (appName, environment) => {
|
|
15
|
-
const { serveDomain, repoName } = getBaseDevEnv();
|
|
16
|
-
return {
|
|
17
|
-
host: `${appName}-${environment}.${serveDomain}`,
|
|
18
|
-
port: process.env.SSU_TUNNEL_PORT ? parseInt(process.env.SSU_TUNNEL_PORT) : 32767,
|
|
19
|
-
username: process.env.SSU_TUNNEL_USERNAME ?? "root",
|
|
20
|
-
password: process.env.SSU_TUNNEL_PASSWORD ?? repoName
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
getBaseDevEnv,
|
|
25
|
-
getSshTunnelOptions
|
|
26
|
-
};
|