gencow 0.1.141 → 0.1.142
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/bin/gencow.mjs +14 -8
- package/core/index.js +83 -77
- package/lib/deploy-command.mjs +5 -1
- package/lib/deploy-runtime.mjs +86 -54
- package/lib/deploy-static-fullstack-runtime.mjs +206 -0
- package/lib/readme-codegen.mjs +7 -7
- package/lib/static-command.mjs +4 -2
- package/lib/static-deploy-command.mjs +2 -2
- package/package.json +1 -1
- package/server/index.js +94 -171
- package/server/index.js.map +4 -4
package/bin/gencow.mjs
CHANGED
|
@@ -81,7 +81,7 @@ import {
|
|
|
81
81
|
import { platformFetch, requireCreds, rpcMutation, rpcQuery } from "../lib/platform-client.mjs";
|
|
82
82
|
|
|
83
83
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
84
|
-
const _drizzleKitCmd = (subcmd) => buildDrizzleKitCommand(subcmd);
|
|
84
|
+
const _drizzleKitCmd = (subcmd, options = {}) => buildDrizzleKitCommand(subcmd, options);
|
|
85
85
|
const generateApiTs = createApiCodegenRuntime({});
|
|
86
86
|
const runAddCommand = createAddCommand({
|
|
87
87
|
loadConfig,
|
|
@@ -197,6 +197,12 @@ const { dev: runDevCommand, devLocal: runDevLocalCommand } = createDevLocalComma
|
|
|
197
197
|
});
|
|
198
198
|
const runConfigCommand = createConfigCommand();
|
|
199
199
|
const runCorsCommand = createCorsCommand();
|
|
200
|
+
const runStaticDeployRuntime = createStaticDeployRuntime({
|
|
201
|
+
cwdImpl: () => process.cwd(),
|
|
202
|
+
drizzleKitCmdImpl: _drizzleKitCmd,
|
|
203
|
+
verifyAppReadyImpl: verifyAppReady,
|
|
204
|
+
updateEnvLocalUrlImpl: updateEnvLocalUrl,
|
|
205
|
+
});
|
|
200
206
|
const runDeployCommand = createDeployCommand({
|
|
201
207
|
cwdImpl: () => process.cwd(),
|
|
202
208
|
drizzleKitCmdImpl: _drizzleKitCmd,
|
|
@@ -213,6 +219,7 @@ const runDeployCommand = createDeployCommand({
|
|
|
213
219
|
resolvePathImpl: resolve,
|
|
214
220
|
rpcMutationImpl: rpcMutation,
|
|
215
221
|
rpcQueryImpl: rpcQuery,
|
|
222
|
+
runStaticDeployRuntimeImpl: runStaticDeployRuntime,
|
|
216
223
|
setTimeoutImpl: setTimeout,
|
|
217
224
|
unlinkSyncImpl: unlinkSync,
|
|
218
225
|
verifyAppReadyImpl: verifyAppReady,
|
|
@@ -225,12 +232,6 @@ const runFilesCommand = createFilesCommand();
|
|
|
225
232
|
const runInitCommand = createInitCommand();
|
|
226
233
|
const runJobsCommand = createJobsCommand();
|
|
227
234
|
const runLogsCommand = createLogsCommand({ loadConfig });
|
|
228
|
-
const runStaticDeployRuntime = createStaticDeployRuntime({
|
|
229
|
-
cwdImpl: () => process.cwd(),
|
|
230
|
-
drizzleKitCmdImpl: _drizzleKitCmd,
|
|
231
|
-
verifyAppReadyImpl: verifyAppReady,
|
|
232
|
-
updateEnvLocalUrlImpl: updateEnvLocalUrl,
|
|
233
|
-
});
|
|
234
235
|
const runStaticCommand = createStaticCommand({
|
|
235
236
|
cwdImpl: () => process.cwd(),
|
|
236
237
|
requireCredsImpl: requireCreds,
|
|
@@ -304,7 +305,7 @@ ${BOLD}Commands (login required):${RESET}
|
|
|
304
305
|
${GREEN}db:generate${RESET} Generate SQL migration files from schema.ts
|
|
305
306
|
${GREEN}db:seed${RESET} Run gencow/seed.ts on cloud app
|
|
306
307
|
${DIM}--prod Seed production app${RESET}
|
|
307
|
-
${GREEN}static [dir]${RESET} Deploy static files ${DIM}(dist/, out/, build/)${RESET}
|
|
308
|
+
${GREEN}static [dir]${RESET} Deploy static files only ${DIM}(dist/, out/, build/)${RESET}
|
|
308
309
|
${DIM}--prod Deploy to production app${RESET}
|
|
309
310
|
${DIM}--force, -f Skip optional dependency scan${RESET}
|
|
310
311
|
${GREEN}templates publish${RESET} Publish current project as a marketplace template
|
|
@@ -312,6 +313,8 @@ ${BOLD}Commands (login required):${RESET}
|
|
|
312
313
|
${GREEN}templates list${RESET} Browse public templates
|
|
313
314
|
${GREEN}templates clone <slug>${RESET} Clone a template into a local directory
|
|
314
315
|
${GREEN}deploy${RESET} Deploy backend to cloud ${DIM}(dev by default)${RESET}
|
|
316
|
+
${DIM}--static [dir] Deploy backend, then static files${RESET}
|
|
317
|
+
${DIM}--no-backend With --static, skip backend deployment${RESET}
|
|
315
318
|
${DIM}--prod Deploy to production (Pro+ only)${RESET}
|
|
316
319
|
${DIM}--rollback Rollback to previous deployment${RESET}
|
|
317
320
|
${DIM}--force, -f Skip optional dependency scan${RESET}
|
|
@@ -362,6 +365,9 @@ ${BOLD}Examples:${RESET}
|
|
|
362
365
|
${DIM}# Deploy to dev:${RESET}
|
|
363
366
|
gencow deploy
|
|
364
367
|
|
|
368
|
+
${DIM}# Deploy backend + built frontend:${RESET}
|
|
369
|
+
gencow deploy --static dist/
|
|
370
|
+
|
|
365
371
|
${DIM}# Deploy to production (Pro+ only):${RESET}
|
|
366
372
|
gencow deploy --prod
|
|
367
373
|
|
package/core/index.js
CHANGED
|
@@ -1585,15 +1585,37 @@ var ragOperationMetrics = pgTable("rag_operation_metrics", {
|
|
|
1585
1585
|
recordedAt: timestamp("recorded_at").defaultNow().notNull()
|
|
1586
1586
|
});
|
|
1587
1587
|
|
|
1588
|
-
// ../core/src/reactive.ts
|
|
1588
|
+
// ../core/src/reactive-query.ts
|
|
1589
1589
|
if (!globalThis.__gencow_queryRegistry) globalThis.__gencow_queryRegistry = /* @__PURE__ */ new Map();
|
|
1590
|
-
|
|
1590
|
+
var queryRegistry = globalThis.__gencow_queryRegistry;
|
|
1591
|
+
function query(key, handlerOrDef) {
|
|
1592
|
+
let handler;
|
|
1593
|
+
let argsSchema;
|
|
1594
|
+
let isPublic = false;
|
|
1595
|
+
if (typeof handlerOrDef === "function") {
|
|
1596
|
+
handler = handlerOrDef;
|
|
1597
|
+
} else {
|
|
1598
|
+
handler = handlerOrDef.handler;
|
|
1599
|
+
argsSchema = handlerOrDef.args;
|
|
1600
|
+
isPublic = handlerOrDef.public === true;
|
|
1601
|
+
}
|
|
1602
|
+
const def = { key, handler, argsSchema, isPublic };
|
|
1603
|
+
queryRegistry.set(key, def);
|
|
1604
|
+
return def;
|
|
1605
|
+
}
|
|
1606
|
+
function getQueryHandler(key) {
|
|
1607
|
+
return queryRegistry.get(key)?.handler;
|
|
1608
|
+
}
|
|
1609
|
+
function getQueryDef(key) {
|
|
1610
|
+
return queryRegistry.get(key);
|
|
1611
|
+
}
|
|
1612
|
+
function getRegisteredQueries() {
|
|
1613
|
+
return Array.from(queryRegistry.keys());
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
// ../core/src/reactive-realtime.ts
|
|
1591
1617
|
if (!globalThis.__gencow_subscribers) globalThis.__gencow_subscribers = /* @__PURE__ */ new Map();
|
|
1592
1618
|
if (!globalThis.__gencow_connectedClients) globalThis.__gencow_connectedClients = /* @__PURE__ */ new Set();
|
|
1593
|
-
if (!globalThis.__gencow_httpActionRegistry) globalThis.__gencow_httpActionRegistry = [];
|
|
1594
|
-
var queryRegistry = globalThis.__gencow_queryRegistry;
|
|
1595
|
-
var mutationRegistry = globalThis.__gencow_mutationRegistry;
|
|
1596
|
-
var httpActionRegistry = globalThis.__gencow_httpActionRegistry;
|
|
1597
1619
|
var subscribers = globalThis.__gencow_subscribers;
|
|
1598
1620
|
var connectedClients = globalThis.__gencow_connectedClients;
|
|
1599
1621
|
var SUBSCRIPTION_KEY_SEPARATOR = "::";
|
|
@@ -1624,69 +1646,6 @@ function buildQuerySubscriptionKey(queryKey, args) {
|
|
|
1624
1646
|
function subscriptionKeyMatchesQueryKey(subscriptionKey, queryKey) {
|
|
1625
1647
|
return subscriptionKey === queryKey || subscriptionKey.startsWith(`${queryKey}${SUBSCRIPTION_KEY_SEPARATOR}`);
|
|
1626
1648
|
}
|
|
1627
|
-
function query(key, handlerOrDef) {
|
|
1628
|
-
let handler;
|
|
1629
|
-
let argsSchema;
|
|
1630
|
-
let isPublic = false;
|
|
1631
|
-
if (typeof handlerOrDef === "function") {
|
|
1632
|
-
handler = handlerOrDef;
|
|
1633
|
-
} else {
|
|
1634
|
-
handler = handlerOrDef.handler;
|
|
1635
|
-
argsSchema = handlerOrDef.args;
|
|
1636
|
-
isPublic = handlerOrDef.public === true;
|
|
1637
|
-
}
|
|
1638
|
-
const def = { key, handler, argsSchema, isPublic };
|
|
1639
|
-
queryRegistry.set(key, def);
|
|
1640
|
-
return def;
|
|
1641
|
-
}
|
|
1642
|
-
var mutationCounter = 0;
|
|
1643
|
-
function mutation(nameOrInvalidatesOrDef, handlerOrDef, name) {
|
|
1644
|
-
let argsSchema;
|
|
1645
|
-
let actualHandler;
|
|
1646
|
-
let mutName;
|
|
1647
|
-
let isPublic = false;
|
|
1648
|
-
if (typeof nameOrInvalidatesOrDef === "string") {
|
|
1649
|
-
mutName = nameOrInvalidatesOrDef;
|
|
1650
|
-
const def2 = handlerOrDef;
|
|
1651
|
-
actualHandler = def2.handler;
|
|
1652
|
-
argsSchema = def2.args;
|
|
1653
|
-
isPublic = def2.public === true;
|
|
1654
|
-
} else if (Array.isArray(nameOrInvalidatesOrDef)) {
|
|
1655
|
-
actualHandler = handlerOrDef;
|
|
1656
|
-
mutName = name || `mutation_${++mutationCounter}`;
|
|
1657
|
-
} else {
|
|
1658
|
-
actualHandler = nameOrInvalidatesOrDef.handler;
|
|
1659
|
-
argsSchema = nameOrInvalidatesOrDef.args;
|
|
1660
|
-
isPublic = nameOrInvalidatesOrDef.public === true;
|
|
1661
|
-
mutName = nameOrInvalidatesOrDef.name || (typeof name === "string" ? name : "") || `mutation_${++mutationCounter}`;
|
|
1662
|
-
}
|
|
1663
|
-
if (mutName.startsWith("mutation_")) {
|
|
1664
|
-
console.warn(
|
|
1665
|
-
`[gencow] mutation registered without explicit name \u2192 "${mutName}". Use mutation("myMutation", { handler }) for better debugging.`
|
|
1666
|
-
);
|
|
1667
|
-
}
|
|
1668
|
-
const def = {
|
|
1669
|
-
name: mutName,
|
|
1670
|
-
handler: actualHandler,
|
|
1671
|
-
argsSchema,
|
|
1672
|
-
isPublic
|
|
1673
|
-
};
|
|
1674
|
-
mutationRegistry.push(def);
|
|
1675
|
-
return def;
|
|
1676
|
-
}
|
|
1677
|
-
function httpAction(def) {
|
|
1678
|
-
const actionDef = {
|
|
1679
|
-
method: def.method,
|
|
1680
|
-
path: def.path,
|
|
1681
|
-
isPublic: def.public === true,
|
|
1682
|
-
handler: def.handler
|
|
1683
|
-
};
|
|
1684
|
-
httpActionRegistry.push(actionDef);
|
|
1685
|
-
return actionDef;
|
|
1686
|
-
}
|
|
1687
|
-
function getRegisteredHttpActions() {
|
|
1688
|
-
return [...httpActionRegistry];
|
|
1689
|
-
}
|
|
1690
1649
|
function subscribe(queryKey, ws) {
|
|
1691
1650
|
connectedClients.add(ws);
|
|
1692
1651
|
if (!subscribers.has(queryKey)) {
|
|
@@ -1839,19 +1798,66 @@ function handleWsMessage(ws, raw) {
|
|
|
1839
1798
|
} catch {
|
|
1840
1799
|
}
|
|
1841
1800
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1801
|
+
|
|
1802
|
+
// ../core/src/reactive-mutation.ts
|
|
1803
|
+
if (!globalThis.__gencow_mutationRegistry) globalThis.__gencow_mutationRegistry = [];
|
|
1804
|
+
var mutationRegistry = globalThis.__gencow_mutationRegistry;
|
|
1805
|
+
var mutationCounter = 0;
|
|
1806
|
+
function mutation(nameOrInvalidatesOrDef, handlerOrDef, name) {
|
|
1807
|
+
let argsSchema;
|
|
1808
|
+
let actualHandler;
|
|
1809
|
+
let mutName;
|
|
1810
|
+
let isPublic = false;
|
|
1811
|
+
if (typeof nameOrInvalidatesOrDef === "string") {
|
|
1812
|
+
mutName = nameOrInvalidatesOrDef;
|
|
1813
|
+
const def2 = handlerOrDef;
|
|
1814
|
+
actualHandler = def2.handler;
|
|
1815
|
+
argsSchema = def2.args;
|
|
1816
|
+
isPublic = def2.public === true;
|
|
1817
|
+
} else if (Array.isArray(nameOrInvalidatesOrDef)) {
|
|
1818
|
+
actualHandler = handlerOrDef;
|
|
1819
|
+
mutName = name || `mutation_${++mutationCounter}`;
|
|
1820
|
+
} else {
|
|
1821
|
+
actualHandler = nameOrInvalidatesOrDef.handler;
|
|
1822
|
+
argsSchema = nameOrInvalidatesOrDef.args;
|
|
1823
|
+
isPublic = nameOrInvalidatesOrDef.public === true;
|
|
1824
|
+
mutName = nameOrInvalidatesOrDef.name || (typeof name === "string" ? name : "") || `mutation_${++mutationCounter}`;
|
|
1825
|
+
}
|
|
1826
|
+
if (mutName.startsWith("mutation_")) {
|
|
1827
|
+
console.warn(
|
|
1828
|
+
`[gencow] mutation registered without explicit name \u2192 "${mutName}". Use mutation("myMutation", { handler }) for better debugging.`
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1831
|
+
const def = {
|
|
1832
|
+
name: mutName,
|
|
1833
|
+
handler: actualHandler,
|
|
1834
|
+
argsSchema,
|
|
1835
|
+
isPublic
|
|
1836
|
+
};
|
|
1837
|
+
mutationRegistry.push(def);
|
|
1838
|
+
return def;
|
|
1850
1839
|
}
|
|
1851
1840
|
function getRegisteredMutations() {
|
|
1852
1841
|
return [...mutationRegistry];
|
|
1853
1842
|
}
|
|
1854
1843
|
|
|
1844
|
+
// ../core/src/http-action.ts
|
|
1845
|
+
if (!globalThis.__gencow_httpActionRegistry) globalThis.__gencow_httpActionRegistry = [];
|
|
1846
|
+
var httpActionRegistry = globalThis.__gencow_httpActionRegistry;
|
|
1847
|
+
function httpAction(def) {
|
|
1848
|
+
const actionDef = {
|
|
1849
|
+
method: def.method,
|
|
1850
|
+
path: def.path,
|
|
1851
|
+
isPublic: def.public === true,
|
|
1852
|
+
handler: def.handler
|
|
1853
|
+
};
|
|
1854
|
+
httpActionRegistry.push(actionDef);
|
|
1855
|
+
return actionDef;
|
|
1856
|
+
}
|
|
1857
|
+
function getRegisteredHttpActions() {
|
|
1858
|
+
return [...httpActionRegistry];
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1855
1861
|
// ../core/src/scheduler.ts
|
|
1856
1862
|
var cron = __toESM(require_node_cron(), 1);
|
|
1857
1863
|
var _cronInfo = globalThis.__gencow_cronInfo ??= [];
|
package/lib/deploy-command.mjs
CHANGED
|
@@ -2,15 +2,19 @@ import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW, error, info, log, success,
|
|
|
2
2
|
import { readProjectAppTargets } from "./cloud-targets.mjs";
|
|
3
3
|
|
|
4
4
|
export function renderDeployHelp() {
|
|
5
|
-
log(`\n${BOLD}${CYAN}gencow deploy${RESET} — Deploy backend to cloud\n`);
|
|
5
|
+
log(`\n${BOLD}${CYAN}gencow deploy${RESET} — Deploy backend or fullstack app to cloud\n`);
|
|
6
6
|
log(` ${BOLD}Usage:${RESET} gencow deploy [options]\n`);
|
|
7
7
|
log(` ${BOLD}Options:${RESET}`);
|
|
8
|
+
log(` ${DIM}--static [dir]${RESET} Deploy backend first, then static files`);
|
|
9
|
+
log(` ${DIM}--no-backend${RESET} With --static, skip backend deployment`);
|
|
8
10
|
log(` ${DIM}--prod${RESET} Deploy to production (Pro+ only)`);
|
|
9
11
|
log(` ${DIM}--rollback${RESET} Rollback to previous deployment`);
|
|
10
12
|
log(` ${DIM}--force, -f${RESET} Skip optional dependency scan`);
|
|
11
13
|
log(` ${DIM}--app, -a${RESET} Target specific app\n`);
|
|
12
14
|
log(` ${BOLD}Examples:${RESET}`);
|
|
13
15
|
log(` gencow deploy`);
|
|
16
|
+
log(` gencow deploy --static dist/`);
|
|
17
|
+
log(` gencow deploy --static --no-backend dist/`);
|
|
14
18
|
log(` gencow deploy --prod`);
|
|
15
19
|
log(` gencow deploy --rollback\n`);
|
|
16
20
|
}
|
package/lib/deploy-runtime.mjs
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { existsSync, readFileSync, unlinkSync, writeFileSync } from "fs";
|
|
2
2
|
import { basename, resolve } from "path";
|
|
3
3
|
import { BOLD, CYAN, DIM, GREEN, RED, RESET, YELLOW, error, info, log, success, warn } from "./output.mjs";
|
|
4
|
-
import { createDeployPackageRuntime
|
|
4
|
+
import { createDeployPackageRuntime } from "./deploy-package-runtime.mjs";
|
|
5
|
+
import {
|
|
6
|
+
createScopedDeployPackageRuntime,
|
|
7
|
+
deployBackendPackage,
|
|
8
|
+
runStaticDeployFlow,
|
|
9
|
+
} from "./deploy-static-fullstack-runtime.mjs";
|
|
10
|
+
import { detectStaticDeployBackend } from "./static-deploy-command.mjs";
|
|
5
11
|
|
|
6
12
|
export function parseDeployArgs(deployArgs) {
|
|
7
13
|
const parsed = {
|
|
@@ -9,7 +15,9 @@ export function parseDeployArgs(deployArgs) {
|
|
|
9
15
|
envTarget: "dev",
|
|
10
16
|
forceDeploy: false,
|
|
11
17
|
isRollback: false,
|
|
12
|
-
|
|
18
|
+
noBackend: false,
|
|
19
|
+
staticDeploy: false,
|
|
20
|
+
staticDirArg: null,
|
|
13
21
|
unknownArg: null,
|
|
14
22
|
};
|
|
15
23
|
|
|
@@ -19,12 +27,25 @@ export function parseDeployArgs(deployArgs) {
|
|
|
19
27
|
else if (arg === "--force" || arg === "-f") parsed.forceDeploy = true;
|
|
20
28
|
else if (arg === "--rollback") parsed.isRollback = true;
|
|
21
29
|
else if (arg === "--app" || arg === "-a") parsed.appId = deployArgs[++index];
|
|
22
|
-
else if (arg === "--static")
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
else if (arg === "--static") {
|
|
31
|
+
parsed.staticDeploy = true;
|
|
32
|
+
const maybeDir = deployArgs[index + 1];
|
|
33
|
+
if (maybeDir && !maybeDir.startsWith("-")) {
|
|
34
|
+
parsed.staticDirArg = maybeDir;
|
|
35
|
+
index += 1;
|
|
36
|
+
}
|
|
37
|
+
} else if (arg.startsWith("--static=")) {
|
|
38
|
+
parsed.staticDeploy = true;
|
|
39
|
+
parsed.staticDirArg = arg.slice("--static=".length) || null;
|
|
40
|
+
} else if (arg === "--no-backend") {
|
|
41
|
+
parsed.noBackend = true;
|
|
25
42
|
} else if (!arg.startsWith("-")) {
|
|
26
|
-
parsed.
|
|
27
|
-
|
|
43
|
+
if (parsed.staticDeploy && !parsed.staticDirArg) {
|
|
44
|
+
parsed.staticDirArg = arg;
|
|
45
|
+
} else {
|
|
46
|
+
parsed.unknownArg = arg;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
28
49
|
}
|
|
29
50
|
}
|
|
30
51
|
|
|
@@ -72,8 +93,8 @@ function showUnknownDeployArgument(arg, { errorImpl = error, infoImpl = info, lo
|
|
|
72
93
|
infoImpl(" gencow deploy --force Skip optional dependency scan");
|
|
73
94
|
logImpl("");
|
|
74
95
|
infoImpl("Static files:");
|
|
75
|
-
infoImpl(" gencow static [dir]
|
|
76
|
-
infoImpl(" gencow static --
|
|
96
|
+
infoImpl(" gencow deploy --static [dir] Deploy backend, then static files");
|
|
97
|
+
infoImpl(" gencow deploy --static --no-backend [dir] Deploy static files only");
|
|
77
98
|
}
|
|
78
99
|
|
|
79
100
|
async function confirmFirstProductionDeploy({ appId, createInterfaceImpl, infoImpl = info, logImpl = log }) {
|
|
@@ -235,8 +256,10 @@ async function runRollbackDeploy({
|
|
|
235
256
|
}
|
|
236
257
|
|
|
237
258
|
export function createDeployCommand({
|
|
259
|
+
createDeployPackageRuntimeImpl = createDeployPackageRuntime,
|
|
238
260
|
createInterfaceImpl,
|
|
239
261
|
cwdImpl = () => process.cwd(),
|
|
262
|
+
detectStaticDeployBackendImpl = detectStaticDeployBackend,
|
|
240
263
|
errorImpl = error,
|
|
241
264
|
existsSyncImpl = existsSync,
|
|
242
265
|
exitImpl = (code) => process.exit(code),
|
|
@@ -249,11 +272,13 @@ export function createDeployCommand({
|
|
|
249
272
|
processEnv = process.env,
|
|
250
273
|
processRef = process,
|
|
251
274
|
readFileSyncImpl = readFileSync,
|
|
275
|
+
readDeployProjectContextImpl = readDeployProjectContext,
|
|
252
276
|
renderDeployHelpImpl,
|
|
253
277
|
requireCredsImpl,
|
|
254
278
|
resolvePathImpl = resolve,
|
|
255
279
|
rpcMutationImpl,
|
|
256
280
|
rpcQueryImpl,
|
|
281
|
+
runStaticDeployRuntimeImpl,
|
|
257
282
|
setTimeoutImpl = setTimeout,
|
|
258
283
|
successImpl = success,
|
|
259
284
|
unlinkSyncImpl = unlinkSync,
|
|
@@ -263,8 +288,8 @@ export function createDeployCommand({
|
|
|
263
288
|
drizzleKitCmdImpl,
|
|
264
289
|
updateEnvLocalUrlImpl,
|
|
265
290
|
} = {}) {
|
|
266
|
-
const
|
|
267
|
-
|
|
291
|
+
const packageRuntimeOptions = {
|
|
292
|
+
createDeployPackageRuntimeImpl,
|
|
268
293
|
drizzleKitCmdImpl,
|
|
269
294
|
errorImpl,
|
|
270
295
|
existsSyncImpl,
|
|
@@ -285,7 +310,10 @@ export function createDeployCommand({
|
|
|
285
310
|
warnImpl,
|
|
286
311
|
writeFileSyncImpl,
|
|
287
312
|
updateEnvLocalUrlImpl,
|
|
288
|
-
}
|
|
313
|
+
};
|
|
314
|
+
const createDeployPackageRuntimeForCwd = (scopedCwdImpl) =>
|
|
315
|
+
createScopedDeployPackageRuntime({ ...packageRuntimeOptions, scopedCwdImpl });
|
|
316
|
+
const deployPackageRuntime = createDeployPackageRuntimeForCwd(cwdImpl);
|
|
289
317
|
|
|
290
318
|
return async function runDeployCommand(...deployArgs) {
|
|
291
319
|
if (deployArgs.includes("--help") || deployArgs.includes("-h")) {
|
|
@@ -307,10 +335,6 @@ export function createDeployCommand({
|
|
|
307
335
|
}
|
|
308
336
|
|
|
309
337
|
const parsed = parseDeployArgs(deployArgs);
|
|
310
|
-
if (parsed.redirectStatic) {
|
|
311
|
-
warnImpl(`${YELLOW}--static is deprecated. Use: gencow static --prod${RESET}`);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
338
|
if (parsed.unknownArg) {
|
|
315
339
|
showUnknownDeployArgument(parsed.unknownArg, { errorImpl, infoImpl, logImpl });
|
|
316
340
|
exitImpl(1);
|
|
@@ -318,8 +342,13 @@ export function createDeployCommand({
|
|
|
318
342
|
}
|
|
319
343
|
|
|
320
344
|
const cwd = cwdImpl();
|
|
321
|
-
const
|
|
322
|
-
cwd,
|
|
345
|
+
const staticBackend = parsed.staticDeploy
|
|
346
|
+
? detectStaticDeployBackendImpl({ cwd, existsSyncImpl, resolvePathImpl })
|
|
347
|
+
: { detectedBackend: false, backendRoot: null };
|
|
348
|
+
const hasDetectedBackend = Boolean(staticBackend.detectedBackend && staticBackend.backendRoot);
|
|
349
|
+
const projectRoot = parsed.staticDeploy && hasDetectedBackend ? staticBackend.backendRoot : cwd;
|
|
350
|
+
const context = readDeployProjectContextImpl({
|
|
351
|
+
cwd: projectRoot,
|
|
323
352
|
explicitAppId: parsed.appId,
|
|
324
353
|
existsSyncImpl,
|
|
325
354
|
readFileSyncImpl,
|
|
@@ -369,48 +398,51 @@ export function createDeployCommand({
|
|
|
369
398
|
infoImpl(`Deploy target: ${CYAN}${appId}${RESET} (production)`);
|
|
370
399
|
}
|
|
371
400
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
infoImpl(`Env: ${parsed.envTarget}${parsed.envTarget === "prod" ? ` ${YELLOW}(production)${RESET}` : ""}`);
|
|
375
|
-
infoImpl("Format: tar.gz");
|
|
376
|
-
logImpl("");
|
|
377
|
-
|
|
378
|
-
const packageResult = await deployPackageRuntime.packageDeployProject({ forceDeploy: parsed.forceDeploy });
|
|
379
|
-
if (!packageResult) return;
|
|
380
|
-
|
|
381
|
-
try {
|
|
382
|
-
const activeAppId = await deployPackageRuntime.createCloudAppIfNeeded({
|
|
383
|
-
creds,
|
|
401
|
+
if (parsed.staticDeploy) {
|
|
402
|
+
return runStaticDeployFlow({
|
|
384
403
|
appId,
|
|
385
|
-
|
|
386
|
-
gencowJsonPath,
|
|
387
|
-
});
|
|
388
|
-
const deployed = await deployPackageRuntime.deployBundleWithRetry({
|
|
404
|
+
backendRoot: staticBackend.backendRoot,
|
|
389
405
|
creds,
|
|
390
|
-
appId: activeAppId,
|
|
391
|
-
bundleBuffer: packageResult.bundleBuffer,
|
|
392
406
|
displayName,
|
|
393
407
|
envTarget: parsed.envTarget,
|
|
408
|
+
forceDeploy: parsed.forceDeploy,
|
|
394
409
|
gencowJsonPath,
|
|
410
|
+
hasDetectedBackend,
|
|
411
|
+
noBackend: parsed.noBackend,
|
|
412
|
+
staticDirArg: parsed.staticDirArg,
|
|
413
|
+
createDeployPackageRuntimeForCwd,
|
|
414
|
+
cwdImpl,
|
|
415
|
+
deployPackageRuntime,
|
|
416
|
+
errorImpl,
|
|
417
|
+
existsSyncImpl,
|
|
418
|
+
exitImpl,
|
|
419
|
+
infoImpl,
|
|
420
|
+
logImpl,
|
|
421
|
+
resolvePathImpl,
|
|
422
|
+
runStaticDeployRuntimeImpl,
|
|
423
|
+
unlinkSyncImpl,
|
|
424
|
+
writeFileSyncImpl,
|
|
395
425
|
});
|
|
396
|
-
if (!deployed) return;
|
|
397
|
-
|
|
398
|
-
if (!existsSyncImpl(gencowJsonPath)) {
|
|
399
|
-
writeProjectMetadata({
|
|
400
|
-
appId: deployed.appId,
|
|
401
|
-
displayName,
|
|
402
|
-
platformUrl: creds.platformUrl,
|
|
403
|
-
gencowJsonPath,
|
|
404
|
-
writeFileSyncImpl,
|
|
405
|
-
});
|
|
406
|
-
infoImpl(`${DIM}gencow.json created${RESET}`);
|
|
407
|
-
}
|
|
408
|
-
} finally {
|
|
409
|
-
try {
|
|
410
|
-
unlinkSyncImpl(packageResult.tmpBundle);
|
|
411
|
-
} catch {
|
|
412
|
-
/* ignore */
|
|
413
|
-
}
|
|
414
426
|
}
|
|
427
|
+
|
|
428
|
+
logImpl(`\n${BOLD}${CYAN}Gencow Deploy${RESET}\n`);
|
|
429
|
+
infoImpl(`App: ${appId ? appId : "new (auto-generated ID)"}`);
|
|
430
|
+
infoImpl(`Env: ${parsed.envTarget}${parsed.envTarget === "prod" ? ` ${YELLOW}(production)${RESET}` : ""}`);
|
|
431
|
+
infoImpl("Format: tar.gz");
|
|
432
|
+
logImpl("");
|
|
433
|
+
|
|
434
|
+
await deployBackendPackage({
|
|
435
|
+
activePackageRuntime: deployPackageRuntime,
|
|
436
|
+
appId,
|
|
437
|
+
creds,
|
|
438
|
+
displayName,
|
|
439
|
+
envTarget: parsed.envTarget,
|
|
440
|
+
forceDeploy: parsed.forceDeploy,
|
|
441
|
+
gencowJsonPath,
|
|
442
|
+
existsSyncImpl,
|
|
443
|
+
infoImpl,
|
|
444
|
+
unlinkSyncImpl,
|
|
445
|
+
writeFileSyncImpl,
|
|
446
|
+
});
|
|
415
447
|
};
|
|
416
448
|
}
|