@nocobase/cli 2.1.0-beta.9 → 2.2.0-beta.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/assets/env-proxy/nginx/app.conf.tpl +23 -0
- package/assets/env-proxy/nginx/nocobase.conf.tpl +5 -0
- package/assets/env-proxy/nginx/snippets/dist-location.conf +5 -0
- package/assets/env-proxy/nginx/snippets/gzip.conf +17 -0
- package/assets/env-proxy/nginx/snippets/log-format-http.conf +13 -0
- package/assets/env-proxy/nginx/snippets/maps-http.conf +14 -0
- package/assets/env-proxy/nginx/snippets/mime-types.conf +98 -0
- package/assets/env-proxy/nginx/snippets/proxy-location.conf +17 -0
- package/assets/env-proxy/nginx/snippets/spa-location.conf +6 -0
- package/assets/env-proxy/nginx/snippets/uploads-location.conf +21 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +145 -0
- package/bin/session-env.js +39 -0
- package/dist/commands/api/resource/create.js +15 -0
- package/dist/commands/api/resource/destroy.js +15 -0
- package/dist/commands/api/resource/get.js +15 -0
- package/dist/commands/api/resource/index.js +20 -0
- package/dist/commands/api/resource/list.js +16 -0
- package/dist/commands/api/resource/query.js +15 -0
- package/dist/commands/api/resource/update.js +15 -0
- package/dist/commands/app/autostart/disable.js +55 -0
- package/dist/commands/app/autostart/enable.js +55 -0
- package/dist/commands/app/autostart/list.js +37 -0
- package/dist/commands/app/autostart/run.js +84 -0
- package/dist/commands/app/autostart/shared.js +49 -0
- package/dist/commands/app/destroy.js +234 -0
- package/dist/commands/app/down.js +71 -0
- package/dist/commands/app/logs.js +115 -0
- package/dist/commands/app/restart.js +229 -0
- package/dist/commands/app/shared.js +123 -0
- package/dist/commands/app/start.js +416 -0
- package/dist/commands/app/stop.js +183 -0
- package/dist/commands/app/upgrade.js +523 -0
- package/dist/commands/backup/create.js +147 -0
- package/dist/commands/backup/index.js +20 -0
- package/dist/commands/backup/restore.js +105 -0
- package/{src/cli.js → dist/commands/build.js} +4 -11
- package/dist/commands/config/delete.js +42 -0
- package/dist/commands/config/get.js +39 -0
- package/dist/commands/config/index.js +20 -0
- package/dist/commands/config/list.js +29 -0
- package/dist/commands/config/set.js +49 -0
- package/dist/commands/db/check.js +240 -0
- package/dist/commands/db/logs.js +85 -0
- package/dist/commands/db/ps.js +47 -0
- package/dist/commands/db/shared.js +96 -0
- package/dist/commands/db/start.js +86 -0
- package/dist/commands/db/stop.js +71 -0
- package/{templates/plugin/src/client/models/index.ts → dist/commands/dev.js} +4 -4
- package/{src/commands/locale/react-js-cron/index.js → dist/commands/down.js} +3 -8
- package/dist/commands/download.js +13 -0
- package/dist/commands/env/add.js +406 -0
- package/dist/commands/env/auth.js +189 -0
- package/dist/commands/env/current.js +21 -0
- package/dist/commands/env/info.js +202 -0
- package/dist/commands/env/list.js +43 -0
- package/dist/commands/env/remove.js +174 -0
- package/dist/commands/env/shared.js +204 -0
- package/dist/commands/env/status.js +93 -0
- package/dist/commands/env/update.js +448 -0
- package/dist/commands/env/use.js +38 -0
- package/dist/commands/examples/prompts-stages.js +150 -0
- package/dist/commands/examples/prompts-test.js +181 -0
- package/dist/commands/init.js +1390 -0
- package/dist/commands/install.js +2609 -0
- package/dist/commands/license/activate.js +179 -0
- package/dist/commands/license/env.js +94 -0
- package/dist/commands/license/generate-id.js +108 -0
- package/dist/commands/license/id.js +70 -0
- package/dist/commands/license/index.js +20 -0
- package/dist/commands/license/plugins/clean.js +115 -0
- package/dist/commands/license/plugins/index.js +20 -0
- package/dist/commands/license/plugins/list.js +64 -0
- package/dist/commands/license/plugins/shared.js +382 -0
- package/dist/commands/license/plugins/sync.js +314 -0
- package/dist/commands/license/shared.js +423 -0
- package/dist/commands/license/status.js +64 -0
- package/dist/commands/logs.js +12 -0
- package/dist/commands/plugin/disable.js +86 -0
- package/dist/commands/plugin/enable.js +86 -0
- package/dist/commands/plugin/import.js +108 -0
- package/dist/commands/plugin/list.js +82 -0
- package/dist/commands/pm/disable.js +12 -0
- package/dist/commands/pm/enable.js +12 -0
- package/dist/commands/pm/list.js +12 -0
- package/dist/commands/proxy/caddy/current.js +17 -0
- package/dist/commands/proxy/caddy/generate.js +69 -0
- package/dist/commands/proxy/caddy/index.js +28 -0
- package/dist/commands/proxy/caddy/info.js +31 -0
- package/dist/commands/proxy/caddy/reload.js +30 -0
- package/dist/commands/proxy/caddy/restart.js +28 -0
- package/dist/commands/proxy/caddy/start.js +30 -0
- package/dist/commands/proxy/caddy/status.js +19 -0
- package/dist/commands/proxy/caddy/stop.js +30 -0
- package/dist/commands/proxy/caddy/use.js +26 -0
- package/dist/commands/proxy/index.js +28 -0
- package/dist/commands/proxy/nginx/current.js +18 -0
- package/dist/commands/proxy/nginx/generate.js +68 -0
- package/dist/commands/proxy/nginx/index.js +28 -0
- package/dist/commands/proxy/nginx/info.js +34 -0
- package/dist/commands/proxy/nginx/reload.js +30 -0
- package/dist/commands/proxy/nginx/restart.js +28 -0
- package/dist/commands/proxy/nginx/start.js +30 -0
- package/dist/commands/proxy/nginx/status.js +19 -0
- package/dist/commands/proxy/nginx/stop.js +30 -0
- package/dist/commands/proxy/nginx/use.js +31 -0
- package/dist/commands/restart.js +12 -0
- package/dist/commands/revision/create.js +118 -0
- package/dist/commands/scaffold/migration.js +38 -0
- package/dist/commands/scaffold/plugin.js +37 -0
- package/dist/commands/self/check.js +71 -0
- package/dist/commands/self/index.js +20 -0
- package/dist/commands/self/update.js +152 -0
- package/dist/commands/session/id.js +24 -0
- package/dist/commands/session/remove.js +57 -0
- package/dist/commands/session/setup.js +62 -0
- package/dist/commands/skills/check.js +69 -0
- package/dist/commands/skills/index.js +20 -0
- package/dist/commands/skills/install.js +80 -0
- package/dist/commands/skills/remove.js +80 -0
- package/dist/commands/skills/update.js +87 -0
- package/dist/commands/source/build.js +58 -0
- package/dist/commands/source/dev.js +182 -0
- package/dist/commands/source/download.js +884 -0
- package/dist/commands/source/publish.js +109 -0
- package/dist/commands/source/registry/logs.js +70 -0
- package/dist/commands/source/registry/start.js +57 -0
- package/dist/commands/source/registry/status.js +33 -0
- package/dist/commands/source/registry/stop.js +48 -0
- package/dist/commands/source/test.js +476 -0
- package/dist/commands/start.js +12 -0
- package/dist/commands/stop.js +12 -0
- package/dist/commands/test.js +12 -0
- package/dist/commands/upgrade.js +12 -0
- package/dist/commands/v1.js +210 -0
- package/dist/generated/command-registry.js +134 -0
- package/dist/help/runtime-help.js +23 -0
- package/dist/lib/api-client.js +335 -0
- package/dist/lib/api-command-compat.js +641 -0
- package/dist/lib/app-health.js +139 -0
- package/dist/lib/app-managed-resources.js +337 -0
- package/dist/lib/app-public-path.js +80 -0
- package/dist/lib/app-runtime.js +189 -0
- package/dist/lib/auth-store.js +528 -0
- package/dist/lib/backup.js +171 -0
- package/dist/lib/bootstrap.js +409 -0
- package/dist/lib/build-config.js +18 -0
- package/dist/lib/builtin-db.js +86 -0
- package/dist/lib/cli-config.js +569 -0
- package/dist/lib/cli-entry-error.js +52 -0
- package/dist/lib/cli-home.js +47 -0
- package/dist/lib/cli-locale.js +141 -0
- package/dist/lib/command-discovery.js +39 -0
- package/dist/lib/command-log.js +284 -0
- package/dist/lib/db-connection-check.js +219 -0
- package/dist/lib/docker-env-file.js +60 -0
- package/dist/lib/docker-image.js +37 -0
- package/dist/lib/docker-log-stream.js +45 -0
- package/dist/lib/env-auth.js +963 -0
- package/dist/lib/env-command-config.js +45 -0
- package/dist/lib/env-config.js +108 -0
- package/dist/lib/env-guard.js +61 -0
- package/dist/lib/env-paths.js +101 -0
- package/dist/lib/env-proxy.js +1325 -0
- package/dist/lib/generated-command.js +203 -0
- package/dist/lib/http-request.js +49 -0
- package/dist/lib/inquirer-theme.js +17 -0
- package/dist/lib/inquirer.js +243 -0
- package/dist/lib/managed-env-file.js +101 -0
- package/dist/lib/managed-init-env.js +32 -0
- package/dist/lib/naming.js +70 -0
- package/dist/lib/object-utils.js +76 -0
- package/dist/lib/openapi.js +62 -0
- package/dist/lib/plugin-import.js +279 -0
- package/dist/lib/plugin-storage.js +64 -0
- package/dist/lib/post-processors.js +23 -0
- package/dist/lib/prompt-catalog-core.js +186 -0
- package/dist/lib/prompt-catalog-terminal.js +374 -0
- package/{src/index.js → dist/lib/prompt-catalog.js} +2 -6
- package/dist/lib/prompt-validators.js +278 -0
- package/dist/lib/prompt-web-ui.js +2234 -0
- package/dist/lib/proxy-caddy.js +274 -0
- package/dist/lib/proxy-nginx.js +330 -0
- package/dist/lib/resource-command.js +357 -0
- package/dist/lib/resource-request.js +104 -0
- package/dist/lib/run-npm.js +429 -0
- package/dist/lib/runtime-env-vars.js +32 -0
- package/dist/lib/runtime-generator.js +498 -0
- package/dist/lib/runtime-store.js +56 -0
- package/dist/lib/self-manager.js +301 -0
- package/dist/lib/session-id.js +17 -0
- package/dist/lib/session-integration.js +703 -0
- package/dist/lib/session-store.js +118 -0
- package/dist/lib/skills-manager.js +438 -0
- package/dist/lib/source-publish.js +326 -0
- package/dist/lib/source-registry.js +188 -0
- package/dist/lib/startup-update.js +309 -0
- package/dist/lib/ui.js +159 -0
- package/dist/locale/en-US.json +526 -0
- package/dist/locale/zh-CN.json +526 -0
- package/dist/post-processors/data-modeling.js +84 -0
- package/dist/post-processors/data-source-manager.js +138 -0
- package/dist/post-processors/index.js +19 -0
- package/nocobase-ctl.config.json +388 -0
- package/package.json +128 -24
- package/scripts/build.mjs +34 -0
- package/scripts/clean.mjs +9 -0
- package/tsconfig.json +19 -0
- package/bin/index.js +0 -39
- package/nocobase.conf.tpl +0 -95
- package/src/commands/benchmark.js +0 -73
- package/src/commands/build.js +0 -49
- package/src/commands/clean.js +0 -30
- package/src/commands/client.js +0 -166
- package/src/commands/create-nginx-conf.js +0 -37
- package/src/commands/create-plugin.js +0 -33
- package/src/commands/dev.js +0 -200
- package/src/commands/doc.js +0 -76
- package/src/commands/e2e.js +0 -265
- package/src/commands/global.js +0 -43
- package/src/commands/index.js +0 -45
- package/src/commands/instance-id.js +0 -47
- package/src/commands/locale/cronstrue.js +0 -122
- package/src/commands/locale/react-js-cron/en-US.json +0 -75
- package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
- package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
- package/src/commands/locale.js +0 -81
- package/src/commands/p-test.js +0 -88
- package/src/commands/perf.js +0 -63
- package/src/commands/pkg.js +0 -321
- package/src/commands/pm2.js +0 -37
- package/src/commands/postinstall.js +0 -88
- package/src/commands/start.js +0 -148
- package/src/commands/tar.js +0 -36
- package/src/commands/test-coverage.js +0 -55
- package/src/commands/test.js +0 -107
- package/src/commands/umi.js +0 -33
- package/src/commands/update-deps.js +0 -72
- package/src/commands/upgrade.js +0 -47
- package/src/commands/view-license-key.js +0 -44
- package/src/license.js +0 -76
- package/src/logger.js +0 -75
- package/src/plugin-generator.js +0 -80
- package/src/util.js +0 -517
- package/templates/bundle-status.html +0 -338
- package/templates/create-app-package.json +0 -39
- package/templates/plugin/.npmignore.tpl +0 -2
- package/templates/plugin/README.md.tpl +0 -1
- package/templates/plugin/client.d.ts +0 -2
- package/templates/plugin/client.js +0 -1
- package/templates/plugin/package.json.tpl +0 -11
- package/templates/plugin/server.d.ts +0 -2
- package/templates/plugin/server.js +0 -1
- package/templates/plugin/src/client/client.d.ts +0 -249
- package/templates/plugin/src/client/index.tsx.tpl +0 -1
- package/templates/plugin/src/client/locale.ts +0 -21
- package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
- package/templates/plugin/src/index.ts +0 -2
- package/templates/plugin/src/locale/en-US.json +0 -1
- package/templates/plugin/src/locale/zh-CN.json +0 -1
- package/templates/plugin/src/server/collections/.gitkeep +0 -0
- package/templates/plugin/src/server/index.ts.tpl +0 -1
- package/templates/plugin/src/server/plugin.ts.tpl +0 -19
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Rendered by `nb env proxy`.
|
|
2
|
+
# Context:
|
|
3
|
+
# publicBasePath={{publicBasePath}}
|
|
4
|
+
# apiBasePath={{apiBasePath}}
|
|
5
|
+
# wsPath={{wsPath}}
|
|
6
|
+
# v2PublicPath={{v2PublicPath}}
|
|
7
|
+
# backendUrl={{backendUrl}}
|
|
8
|
+
# snippetsDir={{snippetsDir}}
|
|
9
|
+
# uploadsDir={{uploadsDir}}
|
|
10
|
+
# distRootDir={{distRootDir}}
|
|
11
|
+
# entryDir={{entryDir}}
|
|
12
|
+
# publicDir={{publicDir}}
|
|
13
|
+
|
|
14
|
+
server {
|
|
15
|
+
listen 80;
|
|
16
|
+
server_name _;
|
|
17
|
+
|
|
18
|
+
# Add custom directives or locations above the managed block as needed.
|
|
19
|
+
|
|
20
|
+
{{managedConfigBlock}}
|
|
21
|
+
|
|
22
|
+
# Add custom directives or locations below the managed block as needed.
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
gzip on;
|
|
2
|
+
gzip_types
|
|
3
|
+
text/plain
|
|
4
|
+
text/css
|
|
5
|
+
text/xml
|
|
6
|
+
text/markdown
|
|
7
|
+
text/javascript
|
|
8
|
+
application/javascript
|
|
9
|
+
application/json
|
|
10
|
+
application/manifest+json
|
|
11
|
+
application/atom+xml
|
|
12
|
+
application/rss+xml
|
|
13
|
+
application/xml
|
|
14
|
+
application/xml+rss
|
|
15
|
+
application/xhtml+xml
|
|
16
|
+
application/wasm
|
|
17
|
+
image/svg+xml;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
log_format apm '"$time_local" client=$remote_addr '
|
|
2
|
+
'method=$request_method request="$request" '
|
|
3
|
+
'request_length=$request_length '
|
|
4
|
+
'status=$status bytes_sent=$bytes_sent '
|
|
5
|
+
'body_bytes_sent=$body_bytes_sent '
|
|
6
|
+
'referer=$http_referer '
|
|
7
|
+
'user_agent="$http_user_agent" '
|
|
8
|
+
'upstream_addr=$upstream_addr '
|
|
9
|
+
'upstream_status=$upstream_status '
|
|
10
|
+
'request_time=$request_time '
|
|
11
|
+
'upstream_response_time=$upstream_response_time '
|
|
12
|
+
'upstream_connect_time=$upstream_connect_time '
|
|
13
|
+
'upstream_header_time=$upstream_header_time';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
map $http_upgrade $connection_upgrade {
|
|
2
|
+
default upgrade;
|
|
3
|
+
"" close;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
map $http_x_forwarded_proto $upstream_x_forwarded_proto {
|
|
7
|
+
default $http_x_forwarded_proto;
|
|
8
|
+
"" $scheme;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
map $http_host $final_host {
|
|
12
|
+
default $http_host;
|
|
13
|
+
"" $host;
|
|
14
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
types {
|
|
2
|
+
text/html html htm shtml;
|
|
3
|
+
text/css css;
|
|
4
|
+
text/xml xml;
|
|
5
|
+
image/gif gif;
|
|
6
|
+
image/jpeg jpeg jpg;
|
|
7
|
+
application/javascript js mjs;
|
|
8
|
+
application/atom+xml atom;
|
|
9
|
+
application/rss+xml rss;
|
|
10
|
+
|
|
11
|
+
text/mathml mml;
|
|
12
|
+
text/plain txt;
|
|
13
|
+
text/vnd.sun.j2me.app-descriptor jad;
|
|
14
|
+
text/vnd.wap.wml wml;
|
|
15
|
+
text/x-component htc;
|
|
16
|
+
|
|
17
|
+
image/avif avif;
|
|
18
|
+
image/png png;
|
|
19
|
+
image/svg+xml svg svgz;
|
|
20
|
+
image/tiff tif tiff;
|
|
21
|
+
image/vnd.wap.wbmp wbmp;
|
|
22
|
+
image/webp webp;
|
|
23
|
+
image/x-icon ico;
|
|
24
|
+
image/x-jng jng;
|
|
25
|
+
image/x-ms-bmp bmp;
|
|
26
|
+
|
|
27
|
+
font/woff woff;
|
|
28
|
+
font/woff2 woff2;
|
|
29
|
+
|
|
30
|
+
application/java-archive jar war ear;
|
|
31
|
+
application/json json;
|
|
32
|
+
application/mac-binhex40 hqx;
|
|
33
|
+
application/msword doc;
|
|
34
|
+
application/pdf pdf;
|
|
35
|
+
application/postscript ps eps ai;
|
|
36
|
+
application/rtf rtf;
|
|
37
|
+
application/vnd.apple.mpegurl m3u8;
|
|
38
|
+
application/vnd.google-earth.kml+xml kml;
|
|
39
|
+
application/vnd.google-earth.kmz kmz;
|
|
40
|
+
application/vnd.ms-excel xls;
|
|
41
|
+
application/vnd.ms-fontobject eot;
|
|
42
|
+
application/vnd.ms-powerpoint ppt;
|
|
43
|
+
application/vnd.oasis.opendocument.graphics odg;
|
|
44
|
+
application/vnd.oasis.opendocument.presentation odp;
|
|
45
|
+
application/vnd.oasis.opendocument.spreadsheet ods;
|
|
46
|
+
application/vnd.oasis.opendocument.text odt;
|
|
47
|
+
application/vnd.openxmlformats-officedocument.presentationml.presentation
|
|
48
|
+
pptx;
|
|
49
|
+
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
|
50
|
+
xlsx;
|
|
51
|
+
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
|
52
|
+
docx;
|
|
53
|
+
application/vnd.wap.wmlc wmlc;
|
|
54
|
+
application/wasm wasm;
|
|
55
|
+
application/x-7z-compressed 7z;
|
|
56
|
+
application/x-cocoa cco;
|
|
57
|
+
application/x-java-archive-diff jardiff;
|
|
58
|
+
application/x-java-jnlp-file jnlp;
|
|
59
|
+
application/x-makeself run;
|
|
60
|
+
application/x-perl pl pm;
|
|
61
|
+
application/x-pilot prc pdb;
|
|
62
|
+
application/x-rar-compressed rar;
|
|
63
|
+
application/x-redhat-package-manager rpm;
|
|
64
|
+
application/x-sea sea;
|
|
65
|
+
application/x-shockwave-flash swf;
|
|
66
|
+
application/x-stuffit sit;
|
|
67
|
+
application/x-tcl tcl tk;
|
|
68
|
+
application/x-x509-ca-cert der pem crt;
|
|
69
|
+
application/x-xpinstall xpi;
|
|
70
|
+
application/xhtml+xml xhtml;
|
|
71
|
+
application/xspf+xml xspf;
|
|
72
|
+
application/zip zip;
|
|
73
|
+
|
|
74
|
+
application/octet-stream bin exe dll;
|
|
75
|
+
application/octet-stream deb;
|
|
76
|
+
application/octet-stream dmg;
|
|
77
|
+
application/octet-stream iso img;
|
|
78
|
+
application/octet-stream msi msp msm;
|
|
79
|
+
|
|
80
|
+
audio/midi mid midi kar;
|
|
81
|
+
audio/mpeg mp3;
|
|
82
|
+
audio/ogg ogg;
|
|
83
|
+
audio/x-m4a m4a;
|
|
84
|
+
audio/x-realaudio ra;
|
|
85
|
+
|
|
86
|
+
video/3gpp 3gpp 3gp;
|
|
87
|
+
video/mp2t ts;
|
|
88
|
+
video/mp4 mp4;
|
|
89
|
+
video/mpeg mpeg mpg;
|
|
90
|
+
video/quicktime mov;
|
|
91
|
+
video/webm webm;
|
|
92
|
+
video/x-flv flv;
|
|
93
|
+
video/x-m4v m4v;
|
|
94
|
+
video/x-mng mng;
|
|
95
|
+
video/x-ms-asf asx asf;
|
|
96
|
+
video/x-ms-wmv wmv;
|
|
97
|
+
video/x-msvideo avi;
|
|
98
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
proxy_http_version 1.1;
|
|
2
|
+
|
|
3
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
4
|
+
proxy_set_header Connection $connection_upgrade;
|
|
5
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
6
|
+
proxy_set_header X-Forwarded-Proto $upstream_x_forwarded_proto;
|
|
7
|
+
proxy_set_header Host $final_host;
|
|
8
|
+
proxy_set_header Referer $http_referer;
|
|
9
|
+
proxy_set_header User-Agent $http_user_agent;
|
|
10
|
+
|
|
11
|
+
add_header Cache-Control "no-cache, no-store" always;
|
|
12
|
+
proxy_cache_bypass $http_upgrade;
|
|
13
|
+
|
|
14
|
+
proxy_connect_timeout 600;
|
|
15
|
+
proxy_send_timeout 600;
|
|
16
|
+
proxy_read_timeout 600;
|
|
17
|
+
send_timeout 600;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
add_header Cache-Control "public" always;
|
|
2
|
+
add_header X-Content-Type-Options "nosniff" always;
|
|
3
|
+
|
|
4
|
+
access_log off;
|
|
5
|
+
autoindex off;
|
|
6
|
+
|
|
7
|
+
# Force potentially renderable uploaded files to download.
|
|
8
|
+
location ~* \.(?:htm|html|svg|svgz|xhtml)$ {
|
|
9
|
+
add_header Cache-Control "public" always;
|
|
10
|
+
add_header X-Content-Type-Options "nosniff" always;
|
|
11
|
+
add_header Content-Disposition "attachment" always;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Let Markdown files render as plain Markdown text.
|
|
15
|
+
location ~* \.md$ {
|
|
16
|
+
default_type text/markdown;
|
|
17
|
+
|
|
18
|
+
add_header Cache-Control "public" always;
|
|
19
|
+
add_header X-Content-Type-Options "nosniff" always;
|
|
20
|
+
add_header Content-Disposition "inline" always;
|
|
21
|
+
}
|
package/bin/run.cmd
ADDED
package/bin/run.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import { createRequire } from 'node:module';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import pc from 'picocolors';
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
9
|
+
import { normalizeNodeOptions, normalizeSessionEnv } from './session-env.js';
|
|
10
|
+
|
|
11
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const requireFromCli = createRequire(import.meta.url);
|
|
13
|
+
const root = path.resolve(__dirname, '..');
|
|
14
|
+
const realRoot = fs.realpathSync(root);
|
|
15
|
+
const isSourcePackage = realRoot.split(path.sep).join('/').endsWith('/packages/core/cli');
|
|
16
|
+
let isDev = isSourcePackage;
|
|
17
|
+
if (process.env.NB_CLI_USE_DIST === '1') {
|
|
18
|
+
isDev = false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
normalizeSessionEnv();
|
|
22
|
+
normalizeNodeOptions();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* In the monorepo, plain `node` cannot load `.ts`. Re-exec once with `--import <tsx>`
|
|
26
|
+
* (same effect as a dedicated dev entry with `#!/usr/bin/env -S node --import tsx`).
|
|
27
|
+
*
|
|
28
|
+
* Use the tsx package resolved from this CLI install (not CWD), so `nb` works when
|
|
29
|
+
* invoked from a project directory that does not depend on `tsx`.
|
|
30
|
+
*/
|
|
31
|
+
function reexecWithTsx() {
|
|
32
|
+
let tsxEntry;
|
|
33
|
+
try {
|
|
34
|
+
tsxEntry = requireFromCli.resolve('tsx');
|
|
35
|
+
} catch {
|
|
36
|
+
console.error(
|
|
37
|
+
[
|
|
38
|
+
'Cannot load dev dependency `tsx` for the NocoBase CLI.',
|
|
39
|
+
'Install monorepo dependencies (e.g. `yarn install` at the repo root),',
|
|
40
|
+
'or set NB_CLI_USE_DIST=1 to run the compiled CLI without TypeScript sources.',
|
|
41
|
+
].join(' '),
|
|
42
|
+
);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const reexecArgs = ['--import', pathToFileURL(tsxEntry).href];
|
|
47
|
+
const supportedFlags = Array.from(process.allowedNodeEnvironmentFlags);
|
|
48
|
+
if (supportedFlags.some((flag) => flag === '--disable-warning' || flag.startsWith('--disable-warning='))) {
|
|
49
|
+
reexecArgs.push('--disable-warning=ExperimentalWarning');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const result = spawnSync(process.execPath, [...reexecArgs, ...process.argv.slice(1)], {
|
|
53
|
+
stdio: 'inherit',
|
|
54
|
+
env: {
|
|
55
|
+
...process.env,
|
|
56
|
+
_NOCO_CLI_TSX_CHILD: '1',
|
|
57
|
+
NODE_ENV: 'development',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (isDev && !process.env._NOCO_CLI_TSX_CHILD) {
|
|
64
|
+
reexecWithTsx();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const bootstrapPath = isDev ? path.join(root, 'src/lib/bootstrap.ts') : path.join(root, 'dist/lib/bootstrap.js');
|
|
68
|
+
const { ensureRuntimeFromArgv } = await import(pathToFileURL(bootstrapPath).href);
|
|
69
|
+
const commandLogPath = isDev ? path.join(root, 'src/lib/command-log.ts') : path.join(root, 'dist/lib/command-log.js');
|
|
70
|
+
const { finalizeCommandLogSessionSync, initCommandLogSession, installCommandLogWriteHooks } = await import(
|
|
71
|
+
pathToFileURL(commandLogPath).href
|
|
72
|
+
);
|
|
73
|
+
const startupUpdatePath = isDev
|
|
74
|
+
? path.join(root, 'src/lib/startup-update.ts')
|
|
75
|
+
: path.join(root, 'dist/lib/startup-update.js');
|
|
76
|
+
const { maybeRunStartupUpdate } = await import(pathToFileURL(startupUpdatePath).href);
|
|
77
|
+
const cliEntryErrorPath = isDev
|
|
78
|
+
? path.join(root, 'src/lib/cli-entry-error.ts')
|
|
79
|
+
: path.join(root, 'dist/lib/cli-entry-error.js');
|
|
80
|
+
const { appendDiagnosticLogPath, formatCliEntryError } = await import(pathToFileURL(cliEntryErrorPath).href);
|
|
81
|
+
const { flush, run, settings } = await import('@oclif/core');
|
|
82
|
+
const forcedColors = pc.createColors(true);
|
|
83
|
+
|
|
84
|
+
if (isDev) {
|
|
85
|
+
settings.debug = true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const cliPackageJson = requireFromCli(path.join(root, 'package.json'));
|
|
89
|
+
const argv = process.argv.slice(2);
|
|
90
|
+
const commandLogSession = await initCommandLogSession({
|
|
91
|
+
argv,
|
|
92
|
+
cwd: process.cwd(),
|
|
93
|
+
sessionId: process.env.NB_SESSION_ID,
|
|
94
|
+
cliVersion: cliPackageJson?.version,
|
|
95
|
+
nodeVersion: process.version,
|
|
96
|
+
platform: process.platform,
|
|
97
|
+
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
98
|
+
verbose: argv.includes('--verbose'),
|
|
99
|
+
});
|
|
100
|
+
const restoreCommandLogHooks = installCommandLogWriteHooks();
|
|
101
|
+
let commandLogFinalized = false;
|
|
102
|
+
|
|
103
|
+
function finalizeCommandLogOnce(options = {}) {
|
|
104
|
+
if (commandLogFinalized) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
commandLogFinalized = true;
|
|
109
|
+
restoreCommandLogHooks?.();
|
|
110
|
+
finalizeCommandLogSessionSync(commandLogSession, options);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
process.once('exit', (code) => {
|
|
114
|
+
finalizeCommandLogOnce({ exitCode: code ?? undefined });
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
try {
|
|
118
|
+
const startupUpdate = await maybeRunStartupUpdate(argv);
|
|
119
|
+
if (startupUpdate.kind === 'updated') {
|
|
120
|
+
const result = spawnSync(process.execPath, process.argv.slice(1), {
|
|
121
|
+
stdio: 'inherit',
|
|
122
|
+
env: {
|
|
123
|
+
...process.env,
|
|
124
|
+
NB_SKIP_STARTUP_UPDATE: '1',
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
128
|
+
}
|
|
129
|
+
if (argv[0] === 'api') {
|
|
130
|
+
await ensureRuntimeFromArgv(argv, {
|
|
131
|
+
configFile: path.join(root, 'nocobase-ctl.config.json'),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
await run(argv, import.meta.url);
|
|
135
|
+
flush();
|
|
136
|
+
finalizeCommandLogOnce({ exitCode: 0 });
|
|
137
|
+
} catch (error) {
|
|
138
|
+
const message = appendDiagnosticLogPath(
|
|
139
|
+
formatCliEntryError(error, process.argv.slice(2)),
|
|
140
|
+
commandLogSession?.logFile,
|
|
141
|
+
);
|
|
142
|
+
console.error(forcedColors.red(message));
|
|
143
|
+
finalizeCommandLogOnce({ exitCode: 1, errorMessage: message });
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const SESSION_ENV_SOURCES = [
|
|
2
|
+
'CODEX_THREAD_ID',
|
|
3
|
+
'OPENCODE_RUN_ID',
|
|
4
|
+
'COPILOT_AGENT_SESSION_ID',
|
|
5
|
+
'CLAUDE_CODE_SESSION_ID',
|
|
6
|
+
];
|
|
7
|
+
const PRESERVE_SYMLINKS_FLAG = '--preserve-symlinks';
|
|
8
|
+
|
|
9
|
+
export function resolveNormalizedSessionId(env = process.env) {
|
|
10
|
+
for (const key of SESSION_ENV_SOURCES) {
|
|
11
|
+
const value = String(env[key] ?? '').trim();
|
|
12
|
+
if (value) {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function normalizeSessionEnv(env = process.env) {
|
|
21
|
+
const sessionId = resolveNormalizedSessionId(env);
|
|
22
|
+
if (!sessionId) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
env.NB_SESSION_ID = sessionId;
|
|
27
|
+
return sessionId;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function normalizeNodeOptions(env = process.env) {
|
|
31
|
+
const currentNodeOptions = String(env.NODE_OPTIONS ?? '').trim();
|
|
32
|
+
const flags = currentNodeOptions ? currentNodeOptions.split(/\s+/) : [];
|
|
33
|
+
|
|
34
|
+
if (!flags.includes(PRESERVE_SYMLINKS_FLAG)) {
|
|
35
|
+
env.NODE_OPTIONS = [...flags, PRESERVE_SYMLINKS_FLAG].join(' ');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return env.NODE_OPTIONS;
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { buildCreateArgs, createFlags, runResourceCommand } from '../../../lib/resource-command.js';
|
|
3
|
+
export default class ResourceCreate extends Command {
|
|
4
|
+
static summary = 'Create a record in a resource';
|
|
5
|
+
static description = 'Create a record in a generic resource. Pass record content through --values as a JSON object.';
|
|
6
|
+
static examples = [
|
|
7
|
+
`<%= config.bin %> <%= command.id %> --resource users --values '{"nickname":"Ada"}'`,
|
|
8
|
+
`<%= config.bin %> <%= command.id %> --resource posts.comments --source-id 1 --values '{"content":"Hello"}'`,
|
|
9
|
+
];
|
|
10
|
+
static flags = createFlags;
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(ResourceCreate);
|
|
13
|
+
await runResourceCommand(this, 'create', flags, buildCreateArgs(flags));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { buildDestroyArgs, destroyFlags, runResourceCommand } from '../../../lib/resource-command.js';
|
|
3
|
+
export default class ResourceDestroy extends Command {
|
|
4
|
+
static summary = 'Delete records from a resource';
|
|
5
|
+
static description = 'Delete records from a generic resource. Target records with --filter-by-tk or --filter.';
|
|
6
|
+
static examples = [
|
|
7
|
+
'<%= config.bin %> <%= command.id %> --resource users --filter-by-tk 1',
|
|
8
|
+
`<%= config.bin %> <%= command.id %> --resource posts --filter '{"status":"archived"}'`,
|
|
9
|
+
];
|
|
10
|
+
static flags = destroyFlags;
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(ResourceDestroy);
|
|
13
|
+
await runResourceCommand(this, 'destroy', flags, buildDestroyArgs(flags));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { buildGetArgs, getFlags, runResourceCommand } from '../../../lib/resource-command.js';
|
|
3
|
+
export default class ResourceGet extends Command {
|
|
4
|
+
static summary = 'Get a record from a resource';
|
|
5
|
+
static description = 'Get a record from a generic resource. Use --filter-by-tk for the primary key and association resource names with --source-id when needed.';
|
|
6
|
+
static examples = [
|
|
7
|
+
'<%= config.bin %> <%= command.id %> --resource users --filter-by-tk 1',
|
|
8
|
+
'<%= config.bin %> <%= command.id %> --resource posts.comments --source-id 1 --filter-by-tk 2',
|
|
9
|
+
];
|
|
10
|
+
static flags = getFlags;
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(ResourceGet);
|
|
13
|
+
await runResourceCommand(this, 'get', flags, buildGetArgs(flags));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Command, loadHelpClass } from '@oclif/core';
|
|
10
|
+
export default class Resource extends Command {
|
|
11
|
+
static summary = 'Work with generic collection resources';
|
|
12
|
+
async run() {
|
|
13
|
+
await this.parse(Resource);
|
|
14
|
+
const Help = await loadHelpClass(this.config);
|
|
15
|
+
await new Help(this.config, this.config.pjson.oclif.helpOptions ?? this.config.pjson.helpOptions).showHelp([
|
|
16
|
+
this.id ?? 'api:resource',
|
|
17
|
+
...this.argv,
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { buildListArgs, listFlags, runResourceCommand } from '../../../lib/resource-command.js';
|
|
3
|
+
export default class ResourceList extends Command {
|
|
4
|
+
static summary = 'List records from a resource';
|
|
5
|
+
static description = 'List records from a generic resource. Use association resource names like posts.comments with --source-id when needed.';
|
|
6
|
+
static examples = [
|
|
7
|
+
'<%= config.bin %> <%= command.id %> --resource users',
|
|
8
|
+
'<%= config.bin %> <%= command.id %> --resource posts.comments --source-id 1 --fields id --fields content',
|
|
9
|
+
`<%= config.bin %> <%= command.id %> --resource users --filter '{"status":"active"}' --sort=-createdAt`,
|
|
10
|
+
];
|
|
11
|
+
static flags = listFlags;
|
|
12
|
+
async run() {
|
|
13
|
+
const { flags } = await this.parse(ResourceList);
|
|
14
|
+
await runResourceCommand(this, 'list', flags, buildListArgs(flags));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { buildQueryArgs, queryFlags, runResourceCommand } from '../../../lib/resource-command.js';
|
|
3
|
+
export default class ResourceQuery extends Command {
|
|
4
|
+
static summary = 'Run an aggregate query on a resource';
|
|
5
|
+
static description = 'Run an aggregate query on a generic resource. Pass measures, dimensions, and orders as JSON arrays.';
|
|
6
|
+
static examples = [
|
|
7
|
+
`<%= config.bin %> <%= command.id %> --resource orders --measures '[{"field":["id"],"aggregation":"count","alias":"count"}]'`,
|
|
8
|
+
`<%= config.bin %> <%= command.id %> --resource orders --dimensions '[{"field":["status"],"alias":"status"}]' --orders '[{"field":["createdAt"],"order":"desc"}]'`,
|
|
9
|
+
];
|
|
10
|
+
static flags = queryFlags;
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(ResourceQuery);
|
|
13
|
+
await runResourceCommand(this, 'query', flags, buildQueryArgs(flags));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { buildUpdateArgs, runResourceCommand, updateFlags } from '../../../lib/resource-command.js';
|
|
3
|
+
export default class ResourceUpdate extends Command {
|
|
4
|
+
static summary = 'Update records in a resource';
|
|
5
|
+
static description = 'Update records in a generic resource. Target records with --filter-by-tk or --filter, and pass updated values through --values.';
|
|
6
|
+
static examples = [
|
|
7
|
+
`<%= config.bin %> <%= command.id %> --resource users --filter-by-tk 1 --values '{"nickname":"Grace"}'`,
|
|
8
|
+
`<%= config.bin %> <%= command.id %> --resource posts --filter '{"status":"draft"}' --values '{"status":"published"}'`,
|
|
9
|
+
];
|
|
10
|
+
static flags = updateFlags;
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(ResourceUpdate);
|
|
13
|
+
await runResourceCommand(this, 'update', flags, buildUpdateArgs(flags));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Command, Flags } from '@oclif/core';
|
|
10
|
+
import { ensureCrossEnvConfirmed, hasExplicitEnvSelection } from '../../../lib/env-guard.js';
|
|
11
|
+
import { getEnv } from '../../../lib/auth-store.js';
|
|
12
|
+
import { formatMissingManagedAppEnvMessage } from '../../../lib/app-runtime.js';
|
|
13
|
+
import { announceTargetEnv } from '../../../lib/ui.js';
|
|
14
|
+
import { updateAutostartSetting } from './shared.js';
|
|
15
|
+
export default class AppAutostartDisable extends Command {
|
|
16
|
+
static description = 'Disable app autostart for the selected env.';
|
|
17
|
+
static examples = [
|
|
18
|
+
'<%= config.bin %> <%= command.id %>',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> --env app1',
|
|
20
|
+
'<%= config.bin %> <%= command.id %> --env app1 --yes',
|
|
21
|
+
];
|
|
22
|
+
static flags = {
|
|
23
|
+
env: Flags.string({
|
|
24
|
+
char: 'e',
|
|
25
|
+
description: 'CLI env name to remove from app autostart. Defaults to the current env when omitted',
|
|
26
|
+
}),
|
|
27
|
+
yes: Flags.boolean({
|
|
28
|
+
char: 'y',
|
|
29
|
+
description: 'Confirm using --env when it targets a different env than the current env',
|
|
30
|
+
default: false,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
async run() {
|
|
34
|
+
const { flags } = await this.parse(AppAutostartDisable);
|
|
35
|
+
const requestedEnv = flags.env?.trim() || undefined;
|
|
36
|
+
if (requestedEnv && hasExplicitEnvSelection(this.argv)) {
|
|
37
|
+
const confirmed = await ensureCrossEnvConfirmed({
|
|
38
|
+
command: this,
|
|
39
|
+
requestedEnv,
|
|
40
|
+
yes: flags.yes,
|
|
41
|
+
});
|
|
42
|
+
if (!confirmed) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const env = await getEnv(requestedEnv);
|
|
47
|
+
if (!env?.name) {
|
|
48
|
+
this.error(formatMissingManagedAppEnvMessage(requestedEnv));
|
|
49
|
+
}
|
|
50
|
+
const envName = env.name;
|
|
51
|
+
await updateAutostartSetting(envName, false);
|
|
52
|
+
announceTargetEnv(envName);
|
|
53
|
+
this.log(`Disabled app autostart for "${envName}".`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Command, Flags } from '@oclif/core';
|
|
10
|
+
import { ensureCrossEnvConfirmed, hasExplicitEnvSelection } from '../../../lib/env-guard.js';
|
|
11
|
+
import { getEnv } from '../../../lib/auth-store.js';
|
|
12
|
+
import { formatMissingManagedAppEnvMessage } from '../../../lib/app-runtime.js';
|
|
13
|
+
import { announceTargetEnv } from '../../../lib/ui.js';
|
|
14
|
+
import { updateAutostartSetting } from './shared.js';
|
|
15
|
+
export default class AppAutostartEnable extends Command {
|
|
16
|
+
static description = 'Enable app autostart for the selected local or Docker env.';
|
|
17
|
+
static examples = [
|
|
18
|
+
'<%= config.bin %> <%= command.id %>',
|
|
19
|
+
'<%= config.bin %> <%= command.id %> --env app1',
|
|
20
|
+
'<%= config.bin %> <%= command.id %> --env app1 --yes',
|
|
21
|
+
];
|
|
22
|
+
static flags = {
|
|
23
|
+
env: Flags.string({
|
|
24
|
+
char: 'e',
|
|
25
|
+
description: 'CLI env name to add to app autostart. Defaults to the current env when omitted',
|
|
26
|
+
}),
|
|
27
|
+
yes: Flags.boolean({
|
|
28
|
+
char: 'y',
|
|
29
|
+
description: 'Confirm using --env when it targets a different env than the current env',
|
|
30
|
+
default: false,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
async run() {
|
|
34
|
+
const { flags } = await this.parse(AppAutostartEnable);
|
|
35
|
+
const requestedEnv = flags.env?.trim() || undefined;
|
|
36
|
+
if (requestedEnv && hasExplicitEnvSelection(this.argv)) {
|
|
37
|
+
const confirmed = await ensureCrossEnvConfirmed({
|
|
38
|
+
command: this,
|
|
39
|
+
requestedEnv,
|
|
40
|
+
yes: flags.yes,
|
|
41
|
+
});
|
|
42
|
+
if (!confirmed) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const env = await getEnv(requestedEnv);
|
|
47
|
+
if (!env?.name) {
|
|
48
|
+
this.error(formatMissingManagedAppEnvMessage(requestedEnv));
|
|
49
|
+
}
|
|
50
|
+
const envName = env.name;
|
|
51
|
+
await updateAutostartSetting(envName, true);
|
|
52
|
+
announceTargetEnv(envName);
|
|
53
|
+
this.log(`Enabled app autostart for "${envName}".`);
|
|
54
|
+
}
|
|
55
|
+
}
|