@gheima/cli 0.9.2 → 0.9.3
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/CHANGELOG.md +6 -0
- package/dist/cli.js +8 -2
- package/dist/git-remote.js +27 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @gheima/cli
|
|
2
2
|
|
|
3
|
+
## 0.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2910318: `gheima deploy` takes `--type WEB|WORKER|STATIC` for the service its first run creates, and a folder of plain HTML files (an `index.html` and nothing that builds or runs a server) now becomes a static site on its own. Plans count static sites apart from services, so on a Free plan whose one service is taken, a static site still deploys instead of hitting the service limit.
|
|
8
|
+
|
|
3
9
|
## 0.9.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ import { completionScript } from './completion.js';
|
|
|
17
17
|
import { callOp, registerGenerated } from './generated.js';
|
|
18
18
|
import { findLink, toDotenv, writeLink } from './link.js';
|
|
19
19
|
import { listSourceFiles, packSource } from './pack.js';
|
|
20
|
-
import { defaultServiceName, gitRemote, gitSubdir } from './git-remote.js';
|
|
20
|
+
import { defaultServiceName, detectServiceType, gitRemote, gitSubdir } from './git-remote.js';
|
|
21
21
|
import { AGENTS_FILE, agentsSection, upsertAgentsMd } from './agents-md.js';
|
|
22
22
|
import { clearPendingLogin, defaultClientName, loadPendingLogin, LoginEnded, LoginStillPending, openBrowser, pollForApproval, savePendingLogin, startDeviceLogin, } from './device-login.js';
|
|
23
23
|
const program = new Command();
|
|
@@ -1152,6 +1152,7 @@ program
|
|
|
1152
1152
|
.option('--timeout <minutes>', 'stop waiting after this long (exit 7)', '30')
|
|
1153
1153
|
.option('--upload', 'upload this folder instead of building from the git remote')
|
|
1154
1154
|
.option('--name <name>', 'name of the service the first deploy creates (default: the folder name)')
|
|
1155
|
+
.option('--type <type>', 'type of the service the first deploy creates: WEB | WORKER | STATIC (default: STATIC for a plain HTML folder, else WEB)')
|
|
1155
1156
|
.option('-y, --yes', 'create the service without asking (needed without a terminal)')
|
|
1156
1157
|
.action(async (ref, opts, cmd) => {
|
|
1157
1158
|
const g = globals(cmd);
|
|
@@ -1202,9 +1203,14 @@ async function serviceToDeploy(client, ref, dir, opts) {
|
|
|
1202
1203
|
return { id: await resolveServiceId(client, ref), created: false };
|
|
1203
1204
|
const remote = opts.upload ? null : gitRemote(dir);
|
|
1204
1205
|
const name = opts.name ?? defaultServiceName(dir);
|
|
1205
|
-
|
|
1206
|
+
const type = (opts.type?.toUpperCase() ?? detectServiceType(dir));
|
|
1207
|
+
if (!['WEB', 'WORKER', 'STATIC'].includes(type)) {
|
|
1208
|
+
throw new UsageError(`--type must be WEB, WORKER or STATIC, not ${opts.type}.`);
|
|
1209
|
+
}
|
|
1210
|
+
await confirmDestructive(opts.yes, `create the ${type === 'STATIC' ? 'static site' : 'service'} "${name}" ${remote ? `from ${remote.url} (${remote.branch})` : 'from the files in this folder'}`);
|
|
1206
1211
|
const created = await client.services.create({
|
|
1207
1212
|
name,
|
|
1213
|
+
type,
|
|
1208
1214
|
...(remote ? { repoUrl: remote.url, repoBranch: remote.branch } : {}),
|
|
1209
1215
|
});
|
|
1210
1216
|
// Run from a subfolder of a repository (a monorepo app): build that folder, not the root. An
|
package/dist/git-remote.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { basename, join } from 'node:path';
|
|
4
4
|
const git = (dir, ...args) => {
|
|
5
5
|
const r = spawnSync('git', ['-C', dir, ...args], { encoding: 'utf8' });
|
|
@@ -65,3 +65,29 @@ export function defaultServiceName(dir) {
|
|
|
65
65
|
export function gitSubdir(dir) {
|
|
66
66
|
return git(dir, 'rev-parse', '--show-prefix').replace(/\/$/, '');
|
|
67
67
|
}
|
|
68
|
+
/** Files that mean the folder is an app with a server or a build, not a bundle of static files. */
|
|
69
|
+
const APP_MARKERS = [
|
|
70
|
+
'package.json',
|
|
71
|
+
'requirements.txt',
|
|
72
|
+
'pyproject.toml',
|
|
73
|
+
'Pipfile',
|
|
74
|
+
'go.mod',
|
|
75
|
+
'Gemfile',
|
|
76
|
+
'composer.json',
|
|
77
|
+
'Cargo.toml',
|
|
78
|
+
'pom.xml',
|
|
79
|
+
'build.gradle',
|
|
80
|
+
'mix.exs',
|
|
81
|
+
'Dockerfile',
|
|
82
|
+
'deno.json',
|
|
83
|
+
];
|
|
84
|
+
/**
|
|
85
|
+
* The service type the first deploy of `dir` creates: STATIC for a plain site (an `index.html`
|
|
86
|
+
* at the root and nothing that builds or runs a server), WEB otherwise. A static site is served
|
|
87
|
+
* by nginx with no runtime, and plans count it apart from services (Free has one of each).
|
|
88
|
+
*/
|
|
89
|
+
export function detectServiceType(dir) {
|
|
90
|
+
if (!existsSync(join(dir, 'index.html')))
|
|
91
|
+
return 'WEB';
|
|
92
|
+
return APP_MARKERS.some((f) => existsSync(join(dir, f))) ? 'WEB' : 'STATIC';
|
|
93
|
+
}
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// GENERATED by scripts/write-version.mjs from package.json. Do not edit.
|
|
2
|
-
export const VERSION = '0.9.
|
|
2
|
+
export const VERSION = '0.9.3';
|