shiply-cli 0.21.0 → 0.22.0
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/dist/bundle.js +4 -2
- package/dist/functions.js +17 -6
- package/dist/index.js +12 -1
- package/package.json +42 -42
package/dist/bundle.js
CHANGED
|
@@ -18,8 +18,10 @@ const WORKER_EXTERNALS = [
|
|
|
18
18
|
...builtinModules.flatMap((m) => [m, `${m}/*`]),
|
|
19
19
|
];
|
|
20
20
|
/** esbuild-bundle a worker entry into one self-contained ESM module, optionally
|
|
21
|
-
* wrapping it (named-fetch → default, and/or asset-first) via a synthetic entry.
|
|
22
|
-
|
|
21
|
+
* wrapping it (named-fetch → default, and/or asset-first) via a synthetic entry.
|
|
22
|
+
* Also used by `function deploy` to compile worker.ts → JS and inline npm deps
|
|
23
|
+
* (e.g. `@neondatabase/serverless`) before upload. */
|
|
24
|
+
export async function bundleWorker(entryAbs, opts = {}) {
|
|
23
25
|
const common = {
|
|
24
26
|
bundle: true,
|
|
25
27
|
format: 'esm',
|
package/dist/functions.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* `parseArgs` in index.ts doesn't have to know about each one. */
|
|
6
6
|
import { readFile } from 'node:fs/promises';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
+
import { bundleWorker } from './bundle.js';
|
|
8
9
|
import { loadApiKey } from './config.js';
|
|
9
10
|
import { api, resolveBase } from './publish.js';
|
|
10
11
|
const headers = (apiKey) => ({
|
|
@@ -96,19 +97,29 @@ async function deployCmd(argv, inherited) {
|
|
|
96
97
|
}
|
|
97
98
|
const apiKey = await getApiKey(flags, 'function');
|
|
98
99
|
const base = resolveBase(flags.base);
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
100
|
+
const filename = flags.ts ? 'worker.ts' : 'worker.js';
|
|
101
|
+
const entryAbs = join(process.cwd(), filename);
|
|
102
|
+
// Pre-read for a friendly "file not found" message (esbuild's is cryptic).
|
|
102
103
|
try {
|
|
103
|
-
|
|
104
|
+
await readFile(entryAbs, 'utf8');
|
|
104
105
|
}
|
|
105
106
|
catch (e) {
|
|
106
107
|
throw new Error(`couldn't read ${filename} from ${process.cwd()} — ${e.message}\n hint: cd into the directory containing your ${filename}, or pass --ts if the file is worker.ts`);
|
|
107
108
|
}
|
|
109
|
+
// Compile (TS→JS) + bundle npm deps client-side via esbuild so imports like
|
|
110
|
+
// `@neondatabase/serverless` work; cloudflare:*/node:* stay external. We then
|
|
111
|
+
// upload plain JS — the platform can't run esbuild on workerd.
|
|
112
|
+
let source;
|
|
113
|
+
try {
|
|
114
|
+
source = await bundleWorker(entryAbs);
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
throw new Error(`couldn't bundle ${filename}: ${e.message}`);
|
|
118
|
+
}
|
|
108
119
|
const row = await api(`${base}/api/v1/sites/${slug}/function`, {
|
|
109
120
|
method: 'POST',
|
|
110
121
|
headers: headers(apiKey),
|
|
111
|
-
body: JSON.stringify({ source, lang }),
|
|
122
|
+
body: JSON.stringify({ source, lang: 'js' }),
|
|
112
123
|
});
|
|
113
124
|
if (flags.json) {
|
|
114
125
|
console.log(JSON.stringify(row, null, 2));
|
|
@@ -117,7 +128,7 @@ async function deployCmd(argv, inherited) {
|
|
|
117
128
|
console.log(`✔ deployed worker for ${slug}`);
|
|
118
129
|
console.log(` script: ${row.cfScriptName}`);
|
|
119
130
|
console.log(` version: ${row.version.slice(0, 12)}`);
|
|
120
|
-
console.log(` source: ${filename} (
|
|
131
|
+
console.log(` source: ${filename} (bundled → js)`);
|
|
121
132
|
console.log(` routes: requests to https://${slug}.shiply.now/* now hit your worker first`);
|
|
122
133
|
}
|
|
123
134
|
async function getFnCmd(argv, inherited) {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { createInterface } from 'node:readline/promises';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
@@ -318,6 +318,17 @@ async function main() {
|
|
|
318
318
|
if (resolved.hint && publishDir !== dir && !bareJsonFlag) {
|
|
319
319
|
console.log(`✔ ${resolved.hint.framework} project detected — publishing ${publishDir}${resolved.hint.spa ? ' with SPA mode' : ''}`);
|
|
320
320
|
}
|
|
321
|
+
// A bare worker.{ts,js} at the publish root ships as a STATIC asset here
|
|
322
|
+
// (downloadable source, never runs). Warn — it deploys separately as a
|
|
323
|
+
// per-site Worker via `shiply function deploy`.
|
|
324
|
+
if (!bareJsonFlag) {
|
|
325
|
+
for (const wf of ['worker.ts', 'worker.js']) {
|
|
326
|
+
if (existsSync(join(publishDir, wf))) {
|
|
327
|
+
console.log(`⚠ ${wf} will be uploaded as a STATIC file (its source is downloadable) and will NOT run as a worker.\n` +
|
|
328
|
+
` Deploy it as a per-site Worker instead: shiply function deploy <slug>${wf.endsWith('.ts') ? ' --ts' : ''}`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
321
332
|
}
|
|
322
333
|
try {
|
|
323
334
|
// same command, same URL: reuse this directory's site automatically
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "shiply-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Publish static sites to shiply.now from the command line
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"bin": {
|
|
8
|
-
"shiply": "dist/index.js"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"dist",
|
|
12
|
-
"skill",
|
|
13
|
-
"README.md"
|
|
14
|
-
],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "tsc -p tsconfig.build.json",
|
|
17
|
-
"prepublishOnly": "pnpm build",
|
|
18
|
-
"test": "vitest run",
|
|
19
|
-
"typecheck": "tsc --noEmit"
|
|
20
|
-
},
|
|
21
|
-
"engines": {
|
|
22
|
-
"node": ">=18"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"shiply",
|
|
26
|
-
"hosting",
|
|
27
|
-
"static",
|
|
28
|
-
"deploy",
|
|
29
|
-
"agents",
|
|
30
|
-
"publish"
|
|
31
|
-
],
|
|
32
|
-
"homepage": "https://shiply.now",
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/node": "^22.15.0",
|
|
35
|
-
"typescript": "^5.8.0",
|
|
36
|
-
"vitest": "^3.1.0"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"esbuild": "^0.25.12",
|
|
40
|
-
"smol-toml": "^1.7.0"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "shiply-cli",
|
|
3
|
+
"version": "0.22.0",
|
|
4
|
+
"description": "Publish static sites to shiply.now from the command line \u00e2\u20ac\u201d instant web hosting for agents.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"shiply": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"skill",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.build.json",
|
|
17
|
+
"prepublishOnly": "pnpm build",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"typecheck": "tsc --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"shiply",
|
|
26
|
+
"hosting",
|
|
27
|
+
"static",
|
|
28
|
+
"deploy",
|
|
29
|
+
"agents",
|
|
30
|
+
"publish"
|
|
31
|
+
],
|
|
32
|
+
"homepage": "https://shiply.now",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^22.15.0",
|
|
35
|
+
"typescript": "^5.8.0",
|
|
36
|
+
"vitest": "^3.1.0"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"esbuild": "^0.25.12",
|
|
40
|
+
"smol-toml": "^1.7.0"
|
|
41
|
+
}
|
|
42
|
+
}
|