@stacksjs/actions 0.70.258 → 0.70.259
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/action.js +1 -80
- package/dist/actions.js +1 -2
- package/dist/add.js +1 -20
- package/dist/ai/request-model-access.js +1 -10
- package/dist/auth/client.js +2 -44
- package/dist/auth/prune.js +1 -35
- package/dist/auth/setup.js +33 -153
- package/dist/auth/token.js +1 -10
- package/dist/blog-admin.js +3 -151
- package/dist/blog.js +33 -271
- package/dist/build/cli.js +1 -6
- package/dist/build/component-library.js +1 -36
- package/dist/build/component-libs.js +1 -2
- package/dist/build/core.js +1 -55
- package/dist/build/desktop.js +4 -61
- package/dist/build/dmg.js +4 -68
- package/dist/build/docs.js +1 -5
- package/dist/build/frontend-static.js +6 -122
- package/dist/build/server.js +1 -6
- package/dist/build/stacks.js +1 -8
- package/dist/build/views.js +1 -16
- package/dist/build-web-component-lib.js +1 -2
- package/dist/build.js +1 -57
- package/dist/bump.js +9 -210
- package/dist/changelog.js +1 -27
- package/dist/check/ports.js +1 -16
- package/dist/clean.js +1 -4
- package/dist/commit.js +1 -12
- package/dist/copy-types.js +1 -9
- package/dist/database/seed.js +1 -26
- package/dist/deploy/create-receipt-rule.js +1 -36
- package/dist/deploy/index.js +29 -1306
- package/dist/dev/api.js +3 -94
- package/dist/dev/components.js +1 -7
- package/dist/dev/csrf.js +1 -28
- package/dist/dev/dashboard-request-routing.js +1 -10
- package/dist/dev/dashboard-utils.js +1 -380
- package/dist/dev/dashboard.js +7 -422
- package/dist/dev/desktop.js +1 -1
- package/dist/dev/docs.js +1 -24
- package/dist/dev/exit-with-parent.d.ts +6 -0
- package/dist/dev/exit-with-parent.js +1 -0
- package/dist/dev/index.js +1 -29
- package/dist/dev/migrate-watcher.js +1 -74
- package/dist/dev/system-tray.js +2 -172
- package/dist/dev/views.js +1 -169
- package/dist/discover-packages.js +1 -32
- package/dist/domains/add.js +1 -61
- package/dist/domains/purchase.js +1 -66
- package/dist/domains/remove.js +1 -24
- package/dist/examples.js +1 -34
- package/dist/find-projects.js +1 -16
- package/dist/fresh.js +1 -17
- package/dist/generate/action-types.js +3 -9
- package/dist/generate/component-meta.js +1 -9
- package/dist/generate/custom-cli-file.js +2 -20
- package/dist/generate/env-files.js +5 -46
- package/dist/generate/ide-helpers.js +1 -8
- package/dist/generate/images.js +1 -26
- package/dist/generate/index.js +1 -166
- package/dist/generate/lib-entries.js +1 -16
- package/dist/generate/pantry-file.js +1 -46
- package/dist/generate/symlink-core.js +1 -2
- package/dist/generate/types.js +1 -3
- package/dist/generate/vschema.js +2 -47
- package/dist/generate/vscode-custom-data.js +1 -9
- package/dist/helpers/api-host.js +1 -7
- package/dist/helpers/component-meta.js +5 -295
- package/dist/helpers/index.js +1 -1
- package/dist/helpers/lib-entries.js +3 -73
- package/dist/helpers/package-json.js +2 -34
- package/dist/helpers/utils.js +1 -130
- package/dist/helpers/vscode-custom-data.js +3 -57
- package/dist/index.js +1 -51
- package/dist/key-generate.js +1 -24
- package/dist/lint/fix.js +1 -4
- package/dist/lint/index.js +1 -4
- package/dist/lint/lint.js +1 -34
- package/dist/lint/stx-gate.js +3 -175
- package/dist/make-command.js +4 -55
- package/dist/make-job.js +3 -29
- package/dist/make-policy.js +4 -53
- package/dist/make-resource.js +3 -33
- package/dist/make.js +7 -323
- package/dist/migrate/database.js +1 -16
- package/dist/migrate/fresh.js +1 -36
- package/dist/prepublish.js +1 -16
- package/dist/queue/clear.js +1 -42
- package/dist/queue/dlq-purge.js +1 -28
- package/dist/queue/dlq-retry.js +1 -35
- package/dist/queue/dlq.js +4 -55
- package/dist/queue/failed.js +4 -69
- package/dist/queue/flush.js +2 -49
- package/dist/queue/inspect.js +7 -154
- package/dist/queue/list.js +4 -69
- package/dist/queue/monitor.js +5 -94
- package/dist/queue/pause.js +1 -28
- package/dist/queue/quarantine.js +2 -42
- package/dist/queue/resume.js +1 -27
- package/dist/queue/retry.js +1 -41
- package/dist/queue/schedule-list.js +4 -33
- package/dist/queue/schedule.js +1 -12
- package/dist/queue/status.js +4 -68
- package/dist/queue/table.js +1 -10
- package/dist/queue/unquarantine.js +1 -27
- package/dist/queue/work.js +1 -57
- package/dist/release-preflight.js +3 -61
- package/dist/release.js +1 -29
- package/dist/route/list.js +2 -78
- package/dist/run-action.js +1 -1
- package/dist/saas/setup.js +1 -9
- package/dist/scaffold-crud.js +12 -137
- package/dist/schedule/run.js +1 -7
- package/dist/search/flush.js +1 -10
- package/dist/search/import.js +1 -10
- package/dist/search/settings-list.js +1 -10
- package/dist/search/settings.js +1 -9
- package/dist/serve/api.js +1 -37
- package/dist/setup/index.js +1 -1
- package/dist/setup/ssl.js +2 -268
- package/dist/stacks.js +1 -316
- package/dist/templates.js +20 -40
- package/dist/test/feature.js +1 -2
- package/dist/test/index.js +1 -2
- package/dist/test/runner.js +1 -38
- package/dist/test/runner.test.js +1 -29
- package/dist/test/ui.js +1 -2
- package/dist/test/unit.js +1 -2
- package/dist/typecheck.js +1 -4
- package/dist/types.js +1 -16
- package/dist/upgrade/binary.js +1 -29
- package/dist/upgrade/framework-hooks.js +1 -40
- package/dist/upgrade/framework-utils.js +2 -259
- package/dist/upgrade/framework.js +11 -484
- package/dist/upgrade/index.js +1 -17
- package/dist/upgrade/package-project.js +1 -150
- package/dist/upgrade/packages.js +17 -243
- package/dist/upgrade/shell.js +3 -40
- package/dist/upgrade.js +1 -38
- package/package.json +18 -18
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { path as p } from "@stacksjs/path";
|
|
4
|
-
import { storage } from "@stacksjs/storage";
|
|
5
|
-
log.info("Generating action types...");
|
|
6
|
-
const domain = "Actions", files = await readdir(p.appPath(domain), { recursive: !0 }), validActions = `// This file is auto-generated by Stacks. Do not edit this file manually.
|
|
1
|
+
import{readdir}from"node:fs/promises";import{log}from"@stacksjs/logging";import{path as p}from"@stacksjs/path";import{storage}from"@stacksjs/storage";log.info("Generating action types...");const domain="Actions",files=await readdir(p.appPath(domain),{recursive:!0}),validActions=`// This file is auto-generated by Stacks. Do not edit this file manually.
|
|
7
2
|
// If you wish to rename an action, please do so by editing the file name.
|
|
8
3
|
//
|
|
9
4
|
// For more information, please visit: https://stacksjs.com/docs
|
|
10
5
|
|
|
11
|
-
export type ActionPath = ${files.filter((file)
|
|
12
|
-
`;
|
|
13
|
-
await storage.writeFile(p.frameworkPath("types/actions.d.ts"), validActions);
|
|
6
|
+
export type ActionPath = ${files.filter((file)=>file.endsWith(".ts")).map((value)=>`'${domain}/${value.replace(".ts","")}'`).join(" | ")}
|
|
7
|
+
`;await storage.writeFile(p.frameworkPath("types/actions.d.ts"),validActions);
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { hasComponents } from "@stacksjs/storage";
|
|
3
|
-
import { generateComponentMeta } from "../helpers/component-meta";
|
|
4
|
-
log.info("Generating component meta...");
|
|
5
|
-
if (hasComponents())
|
|
6
|
-
generateComponentMeta();
|
|
7
|
-
else
|
|
8
|
-
log.info("No components found. Skipping component meta generation.");
|
|
9
|
-
log.success("Generated component meta.");
|
|
1
|
+
import{log}from"@stacksjs/logging";import{hasComponents}from"@stacksjs/storage";import{generateComponentMeta}from"../helpers/component-meta";log.info("Generating component meta...");if(hasComponents())generateComponentMeta();else log.info("No components found. Skipping component meta generation.");log.success("Generated component meta.");
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import process from
|
|
2
|
-
import { cli } from "@stacksjs/config";
|
|
3
|
-
import { log } from "@stacksjs/logging";
|
|
4
|
-
import { projectPath } from "@stacksjs/path";
|
|
5
|
-
import { writeTextFile } from "@stacksjs/storage";
|
|
6
|
-
import { ExitCode } from "@stacksjs/types";
|
|
7
|
-
log.info("Ensuring Component Library Entry Point...");
|
|
8
|
-
if (!cli.command) {
|
|
9
|
-
log.error("No command defined in the CLI configuration");
|
|
10
|
-
process.exit(ExitCode.FatalError);
|
|
11
|
-
}
|
|
12
|
-
await writeTextFile({
|
|
13
|
-
path: projectPath(cli.command),
|
|
14
|
-
data: `#!/usr/bin/env bun
|
|
1
|
+
import process from"node:process";import{cli}from"@stacksjs/config";import{log}from"@stacksjs/logging";import{projectPath}from"@stacksjs/path";import{writeTextFile}from"@stacksjs/storage";import{ExitCode}from"@stacksjs/types";log.info("Ensuring Component Library Entry Point...");if(!cli.command){log.error("No command defined in the CLI configuration");process.exit(ExitCode.FatalError)}await writeTextFile({path:projectPath(cli.command),data:`#!/usr/bin/env bun
|
|
15
2
|
import('./storage/framework/core/buddy/src/custom-cli')
|
|
16
|
-
`
|
|
17
|
-
}).catch((err) => {
|
|
18
|
-
log.error("There was an error generating your custom CLI file.", err);
|
|
19
|
-
process.exit(ExitCode.FatalError);
|
|
20
|
-
});
|
|
21
|
-
log.success("Generated custom CLI file");
|
|
3
|
+
`}).catch((err)=>{log.error("There was an error generating your custom CLI file.",err);process.exit(ExitCode.FatalError)});log.success("Generated custom CLI file");
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { path as p } from "@stacksjs/path";
|
|
4
|
-
import { storage } from "@stacksjs/storage";
|
|
5
|
-
import { envKeys } from "../../../../env";
|
|
6
|
-
log.info("Generating type env files...");
|
|
7
|
-
const envTypes = `
|
|
1
|
+
import{env as e,envEnum}from"@stacksjs/env";import{log}from"@stacksjs/logging";import{path as p}from"@stacksjs/path";import{storage}from"@stacksjs/storage";import{envKeys}from"../../../../env";log.info("Generating type env files...");const envTypes=`
|
|
8
2
|
// This file is auto-generated by Stacks. Do not edit this file manually.
|
|
9
3
|
// If you want to change the environment variables, please edit the .env file.
|
|
10
4
|
//
|
|
@@ -12,55 +6,20 @@ const envTypes = `
|
|
|
12
6
|
|
|
13
7
|
declare module 'bun' {
|
|
14
8
|
namespace env {
|
|
15
|
-
${envKeys.map((key)
|
|
16
|
-
let type = typeof e[key], value = e[key];
|
|
17
|
-
if (!value)
|
|
18
|
-
if (envEnum[key]) {
|
|
19
|
-
type = envEnum[key]?.map((item) => `'${item}'`).join(" | ");
|
|
20
|
-
value = envEnum[key]?.[0];
|
|
21
|
-
} else
|
|
22
|
-
switch (type) {
|
|
23
|
-
case "number":
|
|
24
|
-
value = "0";
|
|
25
|
-
break;
|
|
26
|
-
case "boolean":
|
|
27
|
-
value = !1;
|
|
28
|
-
break;
|
|
29
|
-
default:
|
|
30
|
-
value = "";
|
|
31
|
-
}
|
|
32
|
-
type = "string";
|
|
33
|
-
if (typeof value === "string") {
|
|
34
|
-
if (value.toLowerCase() === "true" || value.toLowerCase() === "false")
|
|
35
|
-
type = "boolean";
|
|
36
|
-
else if (!Number.isNaN(Number.parseFloat(value)) && Number.isFinite(Number(value)))
|
|
37
|
-
type = "number";
|
|
38
|
-
else if (envEnum[key])
|
|
39
|
-
type = envEnum[key].map((item) => `'${item}'`).join(" | ");
|
|
40
|
-
} else if (typeof value === "number")
|
|
41
|
-
type = "number";
|
|
42
|
-
else if (typeof value === "boolean")
|
|
43
|
-
type = "boolean";
|
|
44
|
-
return `const ${key}: ${type}`;
|
|
45
|
-
}).join(`
|
|
9
|
+
${envKeys.map((key)=>{let type=typeof e[key],value=e[key];if(!value)if(envEnum[key]){type=envEnum[key]?.map((item)=>`'${item}'`).join(" | ");value=envEnum[key]?.[0]}else switch(type){case"number":value="0";break;case"boolean":value=!1;break;default:value=""}type="string";if(typeof value==="string"){if(value.toLowerCase()==="true"||value.toLowerCase()==="false")type="boolean";else if(!Number.isNaN(Number.parseFloat(value))&&Number.isFinite(Number(value)))type="number";else if(envEnum[key])type=envEnum[key].map((item)=>`'${item}'`).join(" | ")}else if(typeof value==="number")type="number";else if(typeof value==="boolean")type="boolean";return`const ${key}: ${type}`}).join(`
|
|
46
10
|
`)}
|
|
47
11
|
}
|
|
48
12
|
}
|
|
49
|
-
`;
|
|
50
|
-
await storage.writeFile(p.frameworkPath("types/env.d.ts"), envTypes);
|
|
51
|
-
log.info(" - ./storage/framework/env.ts");
|
|
52
|
-
const env = `
|
|
13
|
+
`;await storage.writeFile(p.frameworkPath("types/env.d.ts"),envTypes);log.info(" - ./storage/framework/env.ts");const env=`
|
|
53
14
|
// This file is auto-generated by Stacks. Do not edit this file manually.
|
|
54
15
|
// If you want to change the environment variables, please edit the .env file.
|
|
55
16
|
//
|
|
56
17
|
// For more information, please visit: https://stacksjs.com/docs
|
|
57
18
|
|
|
58
19
|
export const envKeys = [
|
|
59
|
-
${envKeys.map((key)
|
|
20
|
+
${envKeys.map((key)=>`'${key}'`).join(`,
|
|
60
21
|
`)}
|
|
61
22
|
] as const
|
|
62
23
|
|
|
63
24
|
export type EnvKey = typeof envKeys[number]
|
|
64
|
-
`;
|
|
65
|
-
await storage.writeFile(p.frameworkPath("env.ts"), env);
|
|
66
|
-
log.info(" - ./storage/framework/env.d.ts");
|
|
25
|
+
`;await storage.writeFile(p.frameworkPath("env.ts"),env);log.info(" - ./storage/framework/env.d.ts");
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { hasComponents } from "@stacksjs/storage";
|
|
3
|
-
import { generateVsCodeCustomData, generateWebTypes } from "../helpers/vscode-custom-data";
|
|
4
|
-
if (hasComponents()) {
|
|
5
|
-
await generateWebTypes();
|
|
6
|
-
await generateVsCodeCustomData();
|
|
7
|
-
} else
|
|
8
|
-
log.info("No components found. Skipping IDE helper generation.");
|
|
1
|
+
import{log}from"@stacksjs/logging";import{hasComponents}from"@stacksjs/storage";import{generateVsCodeCustomData,generateWebTypes}from"../helpers/vscode-custom-data";if(hasComponents()){await generateWebTypes();await generateVsCodeCustomData()}else log.info("No components found. Skipping IDE helper generation.");
|
package/dist/generate/images.js
CHANGED
|
@@ -1,26 +1 @@
|
|
|
1
|
-
import { awaitConfig
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { projectPath } from "@stacksjs/path";
|
|
4
|
-
export async function generateProjectImages(options = {}) {
|
|
5
|
-
const images = (await awaitConfig()).images;
|
|
6
|
-
if (!images || !images.social?.enabled && !images.appStore?.enabled && !images.appIcons?.enabled) {
|
|
7
|
-
log.debug("[generate:images] nothing declared in config/images.ts \u2014 skipping");
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const { countGeneratedImages, generateImages } = await import("@stacksjs/image"), result = await generateImages(images, { only: options.only, root: projectPath() }), counts = countGeneratedImages(result);
|
|
11
|
-
if (options.verbose) {
|
|
12
|
-
for (const card of result.social)
|
|
13
|
-
log.info(`[generate:images] ${card.path} \u2192 ${Object.values(card.files).join(", ")}`);
|
|
14
|
-
for (const [display, paths] of Object.entries(result.appStore))
|
|
15
|
-
log.info(`[generate:images] ${display} \u2192 ${paths.length} screenshot(s)`);
|
|
16
|
-
}
|
|
17
|
-
const summary = [
|
|
18
|
-
counts.social ? `${counts.social} social card(s)` : "",
|
|
19
|
-
counts.appStore ? `${counts.appStore} App Store screenshot(s)` : "",
|
|
20
|
-
counts.appIcons ? `${counts.appIcons} icon(s)` : ""
|
|
21
|
-
].filter(Boolean).join(", ");
|
|
22
|
-
if (summary)
|
|
23
|
-
log.success(`Generated ${summary}`);
|
|
24
|
-
else
|
|
25
|
-
log.info("[generate:images] nothing to generate");
|
|
26
|
-
}
|
|
1
|
+
import{awaitConfig}from"@stacksjs/config";import{log}from"@stacksjs/logging";import{projectPath}from"@stacksjs/path";export async function generateProjectImages(options={}){const images=(await awaitConfig()).images;if(!images||!images.social?.enabled&&!images.appStore?.enabled&&!images.appIcons?.enabled){log.debug("[generate:images] nothing declared in config/images.ts \u2014 skipping");return}const{countGeneratedImages,generateImages}=await import("@stacksjs/image"),result=await generateImages(images,{only:options.only,root:projectPath()}),counts=countGeneratedImages(result);if(options.verbose){for(const card of result.social)log.info(`[generate:images] ${card.path} \u2192 ${Object.values(card.files).join(", ")}`);for(const[display,paths]of Object.entries(result.appStore))log.info(`[generate:images] ${display} \u2192 ${paths.length} screenshot(s)`)}const summary=[counts.social?`${counts.social} social card(s)`:"",counts.appStore?`${counts.appStore} App Store screenshot(s)`:"",counts.appIcons?`${counts.appIcons} icon(s)`:""].filter(Boolean).join(", ");if(summary)log.success(`Generated ${summary}`);else log.info("[generate:images] nothing to generate")}
|
package/dist/generate/index.js
CHANGED
|
@@ -1,166 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import process from "node:process";
|
|
3
|
-
import { runCommand } from "@stacksjs/cli";
|
|
4
|
-
import { Action, NpmScript } from "@stacksjs/enums";
|
|
5
|
-
import { log } from "@stacksjs/logging";
|
|
6
|
-
import { frameworkPath, projectPath, storagePath } from "@stacksjs/path";
|
|
7
|
-
import { ExitCode } from "@stacksjs/types";
|
|
8
|
-
import { runNpmScript } from "@stacksjs/utils";
|
|
9
|
-
import { runAction } from "../helpers";
|
|
10
|
-
import { generateVsCodeCustomData as genVsCodeCustomData } from "../helpers/vscode-custom-data";
|
|
11
|
-
import { generateProjectImages } from "./images";
|
|
12
|
-
export { generateProjectImages } from "./images";
|
|
13
|
-
export { generateVSchema } from "./vschema";
|
|
14
|
-
export async function invoke(options) {
|
|
15
|
-
if (options?.types)
|
|
16
|
-
await generateTypes(options);
|
|
17
|
-
else if (options?.entries)
|
|
18
|
-
await generateLibEntries(options);
|
|
19
|
-
else if (options?.webTypes)
|
|
20
|
-
await generateWebTypes(options);
|
|
21
|
-
else if (options?.customData)
|
|
22
|
-
await generateVsCodeCustomData();
|
|
23
|
-
else if (options?.ideHelpers)
|
|
24
|
-
await generateIdeHelpers(options);
|
|
25
|
-
else if (options?.componentMeta)
|
|
26
|
-
await generateComponentMeta();
|
|
27
|
-
else if (options?.coreSymlink)
|
|
28
|
-
await generateCoreSymlink();
|
|
29
|
-
else if (options?.openApiSpec)
|
|
30
|
-
await generateOpenApiSpec();
|
|
31
|
-
else if (options?.images)
|
|
32
|
-
await generateProjectImages({ verbose: options?.verbose });
|
|
33
|
-
}
|
|
34
|
-
export function generate(options) {
|
|
35
|
-
return invoke(options);
|
|
36
|
-
}
|
|
37
|
-
export async function generateLibEntries(options) {
|
|
38
|
-
const result = await runAction(Action.GenerateLibraryEntries, {
|
|
39
|
-
...options,
|
|
40
|
-
cwd: projectPath()
|
|
41
|
-
});
|
|
42
|
-
if (result.isErr) {
|
|
43
|
-
log.error("There was an error generating your library entry points", result.error);
|
|
44
|
-
process.exit(ExitCode.FatalError);
|
|
45
|
-
}
|
|
46
|
-
log.success("Library entry points generated successfully");
|
|
47
|
-
}
|
|
48
|
-
export async function generateWebTypes(options) {
|
|
49
|
-
const result = await runNpmScript(NpmScript.GenerateWebTypes, options);
|
|
50
|
-
if (result.isErr) {
|
|
51
|
-
log.error("There was an error generating the web-types.json file.", result.error);
|
|
52
|
-
process.exit(ExitCode.FatalError);
|
|
53
|
-
}
|
|
54
|
-
log.success("Successfully generated the web-types.json file");
|
|
55
|
-
}
|
|
56
|
-
export async function generateVsCodeCustomData() {
|
|
57
|
-
const result = await genVsCodeCustomData();
|
|
58
|
-
if (result.isErr) {
|
|
59
|
-
log.error("There was an error generating the custom-elements.json file.", result.error);
|
|
60
|
-
process.exit(ExitCode.FatalError);
|
|
61
|
-
}
|
|
62
|
-
await runAction(Action.LintFix, { verbose: !0, cwd: projectPath() });
|
|
63
|
-
log.success("Successfully generated the custom-elements.json file");
|
|
64
|
-
}
|
|
65
|
-
export async function generateIdeHelpers(options) {
|
|
66
|
-
const result = await runNpmScript(NpmScript.GenerateIdeHelpers, options);
|
|
67
|
-
if (result.isErr) {
|
|
68
|
-
log.error("There was an error generating IDE helpers.", result.error);
|
|
69
|
-
process.exit(ExitCode.FatalError);
|
|
70
|
-
}
|
|
71
|
-
await runAction(Action.LintFix, { verbose: !0, cwd: projectPath() });
|
|
72
|
-
log.success("Successfully generated IDE helpers");
|
|
73
|
-
}
|
|
74
|
-
export async function generateComponentMeta() {
|
|
75
|
-
const result = await genVsCodeCustomData();
|
|
76
|
-
if (result.isErr) {
|
|
77
|
-
log.error("There was an error generating your component meta information.", result.error);
|
|
78
|
-
process.exit(ExitCode.FatalError);
|
|
79
|
-
}
|
|
80
|
-
await runAction(Action.LintFix, { verbose: !0, cwd: projectPath() });
|
|
81
|
-
log.success("Successfully generated component meta information");
|
|
82
|
-
}
|
|
83
|
-
export async function generateTypes(options) {
|
|
84
|
-
const result = await runNpmScript(NpmScript.GenerateTypes, {
|
|
85
|
-
cwd: frameworkPath(),
|
|
86
|
-
...options
|
|
87
|
-
});
|
|
88
|
-
if (result.isErr) {
|
|
89
|
-
log.error("There was an error generating your types.", result.error);
|
|
90
|
-
throw result.error instanceof Error ? result.error : Error(String(result.error));
|
|
91
|
-
}
|
|
92
|
-
log.success("Types were generated successfully");
|
|
93
|
-
}
|
|
94
|
-
export async function watchTypes(options) {
|
|
95
|
-
try {
|
|
96
|
-
const manifestPath = `${frameworkPath()}/package.json`, text = fs.existsSync(manifestPath) ? fs.readFileSync(manifestPath, "utf-8") : "";
|
|
97
|
-
if (!(text ? JSON.parse(text) : {})?.scripts?.["generate:types"]) {
|
|
98
|
-
log.warn("[generate:types --watch] no `generate:types` script in framework package.json \u2014 type regeneration disabled. dev:api will keep running, but type definitions won't auto-refresh on model/config changes.");
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
} catch {}
|
|
102
|
-
const watched = [
|
|
103
|
-
projectPath("app/Models"),
|
|
104
|
-
storagePath("framework/defaults/app/Models"),
|
|
105
|
-
projectPath("config"),
|
|
106
|
-
projectPath("database/migrations")
|
|
107
|
-
];
|
|
108
|
-
log.info(`[generate:types --watch] watching ${watched.length} directories`);
|
|
109
|
-
let pending = null, inflight = !1;
|
|
110
|
-
const trigger = () => {
|
|
111
|
-
if (pending)
|
|
112
|
-
clearTimeout(pending);
|
|
113
|
-
pending = setTimeout(async () => {
|
|
114
|
-
if (inflight)
|
|
115
|
-
return;
|
|
116
|
-
inflight = !0;
|
|
117
|
-
try {
|
|
118
|
-
log.info("[generate:types --watch] change detected, regenerating\u2026");
|
|
119
|
-
await generateTypes(options);
|
|
120
|
-
log.success("[generate:types --watch] types up to date");
|
|
121
|
-
} catch (err) {
|
|
122
|
-
log.error("[generate:types --watch] regeneration failed:", err);
|
|
123
|
-
} finally {
|
|
124
|
-
inflight = !1;
|
|
125
|
-
}
|
|
126
|
-
}, 200);
|
|
127
|
-
}, watchers = [];
|
|
128
|
-
for (const dir of watched)
|
|
129
|
-
try {
|
|
130
|
-
if (!fs.existsSync(dir))
|
|
131
|
-
continue;
|
|
132
|
-
const w = fs.watch(dir, { recursive: !0 }, () => trigger());
|
|
133
|
-
watchers.push(w);
|
|
134
|
-
} catch (err) {
|
|
135
|
-
log.warn(`[generate:types --watch] cannot watch ${dir}: ${err}`);
|
|
136
|
-
}
|
|
137
|
-
if (watchers.length === 0) {
|
|
138
|
-
log.warn("[generate:types --watch] no directories to watch \u2014 exiting");
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
await new Promise((resolve) => {
|
|
142
|
-
process.once("SIGINT", () => {
|
|
143
|
-
log.info("[generate:types --watch] stopping");
|
|
144
|
-
for (const w of watchers)
|
|
145
|
-
try {
|
|
146
|
-
w.close();
|
|
147
|
-
} catch {}
|
|
148
|
-
resolve();
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
export function generatePantryConfig() {
|
|
153
|
-
log.success("Successfully generated `./pantry.yaml` based on your config");
|
|
154
|
-
}
|
|
155
|
-
export async function generateSeeder() {}
|
|
156
|
-
export async function generateCoreSymlink() {
|
|
157
|
-
const link = projectPath(".framework");
|
|
158
|
-
if (fs.existsSync(link))
|
|
159
|
-
await runCommand(`rm -f ${link}`);
|
|
160
|
-
await runCommand(`ln -s ${frameworkPath()} ${link}`);
|
|
161
|
-
}
|
|
162
|
-
export async function generateOpenApiSpec() {
|
|
163
|
-
const { generateOpenApi } = await import("@stacksjs/api");
|
|
164
|
-
await generateOpenApi();
|
|
165
|
-
log.success("Successfully generated Open API Spec");
|
|
166
|
-
}
|
|
1
|
+
import*as fs from"node:fs";import process from"node:process";import{runCommand}from"@stacksjs/cli";import{Action,NpmScript}from"@stacksjs/enums";import{log}from"@stacksjs/logging";import{frameworkPath,projectPath,storagePath}from"@stacksjs/path";import{ExitCode}from"@stacksjs/types";import{runNpmScript}from"@stacksjs/utils";import{runAction}from"../helpers";import{generateVsCodeCustomData as genVsCodeCustomData}from"../helpers/vscode-custom-data";import{generateProjectImages}from"./images";export{generateProjectImages}from"./images";export{generateVSchema}from"./vschema";export async function invoke(options){if(options?.types)await generateTypes(options);else if(options?.entries)await generateLibEntries(options);else if(options?.webTypes)await generateWebTypes(options);else if(options?.customData)await generateVsCodeCustomData();else if(options?.ideHelpers)await generateIdeHelpers(options);else if(options?.componentMeta)await generateComponentMeta();else if(options?.coreSymlink)await generateCoreSymlink();else if(options?.openApiSpec)await generateOpenApiSpec();else if(options?.images)await generateProjectImages({verbose:options?.verbose})}export function generate(options){return invoke(options)}export async function generateLibEntries(options){const result=await runAction(Action.GenerateLibraryEntries,{...options,cwd:projectPath()});if(result.isErr){log.error("There was an error generating your library entry points",result.error);process.exit(ExitCode.FatalError)}log.success("Library entry points generated successfully")}export async function generateWebTypes(options){const result=await runNpmScript(NpmScript.GenerateWebTypes,options);if(result.isErr){log.error("There was an error generating the web-types.json file.",result.error);process.exit(ExitCode.FatalError)}log.success("Successfully generated the web-types.json file")}export async function generateVsCodeCustomData(){const result=await genVsCodeCustomData();if(result.isErr){log.error("There was an error generating the custom-elements.json file.",result.error);process.exit(ExitCode.FatalError)}await runAction(Action.LintFix,{verbose:!0,cwd:projectPath()});log.success("Successfully generated the custom-elements.json file")}export async function generateIdeHelpers(options){const result=await runNpmScript(NpmScript.GenerateIdeHelpers,options);if(result.isErr){log.error("There was an error generating IDE helpers.",result.error);process.exit(ExitCode.FatalError)}await runAction(Action.LintFix,{verbose:!0,cwd:projectPath()});log.success("Successfully generated IDE helpers")}export async function generateComponentMeta(){const result=await genVsCodeCustomData();if(result.isErr){log.error("There was an error generating your component meta information.",result.error);process.exit(ExitCode.FatalError)}await runAction(Action.LintFix,{verbose:!0,cwd:projectPath()});log.success("Successfully generated component meta information")}export async function generateTypes(options){const result=await runNpmScript(NpmScript.GenerateTypes,{cwd:frameworkPath(),...options});if(result.isErr){log.error("There was an error generating your types.",result.error);throw result.error instanceof Error?result.error:Error(String(result.error))}log.success("Types were generated successfully")}export async function watchTypes(options){try{const manifestPath=`${frameworkPath()}/package.json`,text=fs.existsSync(manifestPath)?fs.readFileSync(manifestPath,"utf-8"):"";if(!(text?JSON.parse(text):{})?.scripts?.["generate:types"]){log.warn("[generate:types --watch] no `generate:types` script in framework package.json \u2014 type regeneration disabled. dev:api will keep running, but type definitions won't auto-refresh on model/config changes.");return}}catch{}const watched=[projectPath("app/Models"),storagePath("framework/defaults/app/Models"),projectPath("config"),projectPath("database/migrations")];log.info(`[generate:types --watch] watching ${watched.length} directories`);let pending=null,inflight=!1;const trigger=()=>{if(pending)clearTimeout(pending);pending=setTimeout(async()=>{if(inflight)return;inflight=!0;try{log.info("[generate:types --watch] change detected, regenerating\u2026");await generateTypes(options);log.success("[generate:types --watch] types up to date")}catch(err){log.error("[generate:types --watch] regeneration failed:",err)}finally{inflight=!1}},200)},watchers=[];for(const dir of watched)try{if(!fs.existsSync(dir))continue;const w=fs.watch(dir,{recursive:!0},()=>trigger());watchers.push(w)}catch(err){log.warn(`[generate:types --watch] cannot watch ${dir}: ${err}`)}if(watchers.length===0){log.warn("[generate:types --watch] no directories to watch \u2014 exiting");return}await new Promise((resolve)=>{process.once("SIGINT",()=>{log.info("[generate:types --watch] stopping");for(const w of watchers)try{w.close()}catch{}resolve()})})}export function generatePantryConfig(){log.success("Successfully generated `./pantry.yaml` based on your config")}export async function generateSeeder(){}export async function generateCoreSymlink(){const link=projectPath(".framework");if(fs.existsSync(link))await runCommand(`rm -f ${link}`);await runCommand(`ln -s ${frameworkPath()} ${link}`)}export async function generateOpenApiSpec(){const{generateOpenApi}=await import("@stacksjs/api");await generateOpenApi();log.success("Successfully generated Open API Spec")}
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { log } from "@stacksjs/logging";
|
|
3
|
-
import { hasComponents, hasFunctions } from "@stacksjs/storage";
|
|
4
|
-
import { generateLibEntry } from "../helpers/lib-entries";
|
|
5
|
-
export async function generateLibEntries() {
|
|
6
|
-
log.info("Generating library entry points...");
|
|
7
|
-
if (library.releaseable && hasComponents())
|
|
8
|
-
await generateLibEntry("web-components");
|
|
9
|
-
else
|
|
10
|
-
log.info("No components found. Skipping building component entry points.");
|
|
11
|
-
if (library.releaseable && hasFunctions())
|
|
12
|
-
await generateLibEntry("functions");
|
|
13
|
-
else
|
|
14
|
-
log.info("No functions found. Skipping building function entry point.");
|
|
15
|
-
}
|
|
16
|
-
await generateLibEntries();
|
|
1
|
+
import{library}from"@stacksjs/config";import{log}from"@stacksjs/logging";import{hasComponents,hasFunctions}from"@stacksjs/storage";import{generateLibEntry}from"../helpers/lib-entries";export async function generateLibEntries(){log.info("Generating library entry points...");if(library.releaseable&&hasComponents())await generateLibEntry("web-components");else log.info("No components found. Skipping building component entry points.");if(library.releaseable&&hasFunctions())await generateLibEntry("functions");else log.info("No functions found. Skipping building function entry point.")}await generateLibEntries();
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
import { log, runCommand }
|
|
2
|
-
import { config } from "@stacksjs/config";
|
|
3
|
-
const pantryFile = Bun.file(new URL("../../../../../pantry.yaml", import.meta.url));
|
|
4
|
-
if (!await pantryFile.exists())
|
|
5
|
-
throw Error("pantry.yaml file not found");
|
|
6
|
-
const data = Bun.YAML.parse(await pantryFile.text());
|
|
7
|
-
if (data.dependencies["aws.amazon.com/cdk"] === void 0) {
|
|
8
|
-
log.info("aws.amazon.com/cdk dependency not found in pantry.yaml.");
|
|
9
|
-
if ((await runCommand("which cdk")).isErr)
|
|
10
|
-
throw Error("aws.amazon.com/cdk dependency not found in pantry.yaml. To confirm, run `which cdk`");
|
|
11
|
-
}
|
|
12
|
-
if (data.dependencies["aws.amazon.com/cli"] === void 0) {
|
|
13
|
-
log.info("aws.amazon.com/cli dependency not found in pantry.yaml.");
|
|
14
|
-
if ((await runCommand("which aws")).isErr)
|
|
15
|
-
throw Error("aws.amazon.com/cli dependency not found in pantry.yaml. To confirm, run `which aws`");
|
|
16
|
-
}
|
|
17
|
-
if (data.dependencies["bun.sh"] === void 0) {
|
|
18
|
-
log.info("bun.sh dependency not found in pantry.yaml.");
|
|
19
|
-
if ((await runCommand("which bun")).isErr)
|
|
20
|
-
throw Error("bun.sh dependency not found in pantry.yaml. To confirm, run `which bun`");
|
|
21
|
-
}
|
|
22
|
-
if (data.dependencies["info-zip.org/zip"] === void 0) {
|
|
23
|
-
log.info("info-zip.org/zip dependency not found in pantry.yaml.");
|
|
24
|
-
if ((await runCommand("which zip")).isErr)
|
|
25
|
-
throw Error("info-zip.org/zip dependency not found in pantry.yaml. To confirm, run `which zip`");
|
|
26
|
-
}
|
|
27
|
-
if (data.dependencies["info-zip.org/unzip"] === void 0) {
|
|
28
|
-
log.info("info-zip.org/unzip dependency not found in pantry.yaml.");
|
|
29
|
-
if ((await runCommand("which unzip")).isErr)
|
|
30
|
-
throw Error("info-zip.org/unzip dependency not found in pantry.yaml. To confirm, run `which unzip`");
|
|
31
|
-
}
|
|
32
|
-
if (data.dependencies["mailpit.axllent.org"] === void 0) {
|
|
33
|
-
log.info("mailpit.axllent.org dependency not found in pantry.yaml.");
|
|
34
|
-
if ((await runCommand("which mailpit")).isErr)
|
|
35
|
-
throw Error("mailpit.axllent.org dependency not found in pantry.yaml. To confirm, run `which mailpit`");
|
|
36
|
-
}
|
|
37
|
-
if (data.dependencies["redis.io"] === void 0) {
|
|
38
|
-
log.info("redis.io dependency not found in pantry.yaml.");
|
|
39
|
-
if ((await runCommand("which redis")).isErr)
|
|
40
|
-
throw Error("redis.io dependency not found in pantry.yaml. To confirm, run `which redis`");
|
|
41
|
-
}
|
|
42
|
-
if (config.database.default === "sqlite" && data.dependencies["sqlite.org"] === void 0) {
|
|
43
|
-
log.info("sqlite.org dependency not found in pantry.yaml.");
|
|
44
|
-
if ((await runCommand("which sqlite")).isErr)
|
|
45
|
-
throw Error("sqlite.org dependency not found in pantry.yaml. To confirm, run `which sqlite`");
|
|
46
|
-
}
|
|
1
|
+
import{log,runCommand}from"@stacksjs/cli";import{config}from"@stacksjs/config";const pantryFile=Bun.file(new URL("../../../../../pantry.yaml",import.meta.url));if(!await pantryFile.exists())throw Error("pantry.yaml file not found");const data=Bun.YAML.parse(await pantryFile.text());if(data.dependencies["aws.amazon.com/cdk"]===void 0){log.info("aws.amazon.com/cdk dependency not found in pantry.yaml.");if((await runCommand("which cdk")).isErr)throw Error("aws.amazon.com/cdk dependency not found in pantry.yaml. To confirm, run `which cdk`")}if(data.dependencies["aws.amazon.com/cli"]===void 0){log.info("aws.amazon.com/cli dependency not found in pantry.yaml.");if((await runCommand("which aws")).isErr)throw Error("aws.amazon.com/cli dependency not found in pantry.yaml. To confirm, run `which aws`")}if(data.dependencies["bun.sh"]===void 0){log.info("bun.sh dependency not found in pantry.yaml.");if((await runCommand("which bun")).isErr)throw Error("bun.sh dependency not found in pantry.yaml. To confirm, run `which bun`")}if(data.dependencies["info-zip.org/zip"]===void 0){log.info("info-zip.org/zip dependency not found in pantry.yaml.");if((await runCommand("which zip")).isErr)throw Error("info-zip.org/zip dependency not found in pantry.yaml. To confirm, run `which zip`")}if(data.dependencies["info-zip.org/unzip"]===void 0){log.info("info-zip.org/unzip dependency not found in pantry.yaml.");if((await runCommand("which unzip")).isErr)throw Error("info-zip.org/unzip dependency not found in pantry.yaml. To confirm, run `which unzip`")}if(data.dependencies["mailpit.axllent.org"]===void 0){log.info("mailpit.axllent.org dependency not found in pantry.yaml.");if((await runCommand("which mailpit")).isErr)throw Error("mailpit.axllent.org dependency not found in pantry.yaml. To confirm, run `which mailpit`")}if(data.dependencies["redis.io"]===void 0){log.info("redis.io dependency not found in pantry.yaml.");if((await runCommand("which redis")).isErr)throw Error("redis.io dependency not found in pantry.yaml. To confirm, run `which redis`")}if(config.database.default==="sqlite"&&data.dependencies["sqlite.org"]===void 0){log.info("sqlite.org dependency not found in pantry.yaml.");if((await runCommand("which sqlite")).isErr)throw Error("sqlite.org dependency not found in pantry.yaml. To confirm, run `which sqlite`")}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
await generateCoreSymlink();
|
|
1
|
+
import{generateCoreSymlink}from"@stacksjs/actions";await generateCoreSymlink();
|
package/dist/generate/types.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
log.info("Generating types for ./resources/components & ./resources/function");
|
|
3
|
-
log.info("Generated types saved in ./storage/framework/types/*");
|
|
1
|
+
import{log}from"@stacksjs/cli";log.info("Generating types for ./resources/components & ./resources/function");log.info("Generated types saved in ./storage/framework/types/*");
|
package/dist/generate/vschema.js
CHANGED
|
@@ -1,47 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { log } from "@stacksjs/logging";
|
|
4
|
-
import { path } from "@stacksjs/path";
|
|
5
|
-
import { fs } from "@stacksjs/storage";
|
|
6
|
-
function tableNameFor(definition, fileName) {
|
|
7
|
-
if (definition?.table)
|
|
8
|
-
return definition.table;
|
|
9
|
-
const snake = (definition?.name ?? fileName).replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
|
|
10
|
-
if (/(?:s|x|z|ch|sh)$/.test(snake))
|
|
11
|
-
return `${snake}es`;
|
|
12
|
-
if (/[^aeiou]y$/.test(snake))
|
|
13
|
-
return `${snake.slice(0, -1)}ies`;
|
|
14
|
-
return `${snake}s`;
|
|
15
|
-
}
|
|
16
|
-
export async function generateVSchema(options = {}) {
|
|
17
|
-
const sources = resolveModelSources();
|
|
18
|
-
if (!sources || sources.models.length === 0)
|
|
19
|
-
return { ok: !1, error: "No models found. A VSchema is derived from your models, so there is nothing to generate." };
|
|
20
|
-
const models = [], failed = [];
|
|
21
|
-
for (const source of sources.models)
|
|
22
|
-
try {
|
|
23
|
-
const definition = (await import(source.file)).default;
|
|
24
|
-
if (!definition)
|
|
25
|
-
continue;
|
|
26
|
-
models.push(toShardableModel(definition, tableNameFor(definition, source.name)));
|
|
27
|
-
} catch (error) {
|
|
28
|
-
failed.push(`${source.name}: ${error.message}`);
|
|
29
|
-
}
|
|
30
|
-
for (const failure of failed)
|
|
31
|
-
log.warn(`[generate:vschema] skipped ${failure}`);
|
|
32
|
-
if (models.length === 0)
|
|
33
|
-
return { ok: !1, error: "Every model failed to load; nothing to derive a VSchema from." };
|
|
34
|
-
const { vschema, decisions } = deriveVSchema(models), report = formatShardingReport(decisions), outPath = path.projectPath(options.out ?? "database/vschema.json");
|
|
35
|
-
if (!options.dryRun) {
|
|
36
|
-
fs.mkdirSync(dirname(outPath), { recursive: !0 });
|
|
37
|
-
await Bun.write(outPath, `${JSON.stringify(vschema, null, 2)}
|
|
38
|
-
`);
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
ok: !0,
|
|
42
|
-
vschema,
|
|
43
|
-
report,
|
|
44
|
-
path: outPath,
|
|
45
|
-
tableCount: Object.keys(vschema.tables).length
|
|
46
|
-
};
|
|
47
|
-
}
|
|
1
|
+
import{dirname}from"node:path";import{deriveVSchema,formatShardingReport,resolveModelSources,toShardableModel}from"@stacksjs/database";import{log}from"@stacksjs/logging";import{path}from"@stacksjs/path";import{fs}from"@stacksjs/storage";function tableNameFor(definition,fileName){if(definition?.table)return definition.table;const snake=(definition?.name??fileName).replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase();if(/(?:s|x|z|ch|sh)$/.test(snake))return`${snake}es`;if(/[^aeiou]y$/.test(snake))return`${snake.slice(0,-1)}ies`;return`${snake}s`}export async function generateVSchema(options={}){const sources=resolveModelSources();if(!sources||sources.models.length===0)return{ok:!1,error:"No models found. A VSchema is derived from your models, so there is nothing to generate."};const models=[],failed=[];for(const source of sources.models)try{const definition=(await import(source.file)).default;if(!definition)continue;models.push(toShardableModel(definition,tableNameFor(definition,source.name)))}catch(error){failed.push(`${source.name}: ${error.message}`)}for(const failure of failed)log.warn(`[generate:vschema] skipped ${failure}`);if(models.length===0)return{ok:!1,error:"Every model failed to load; nothing to derive a VSchema from."};const{vschema,decisions}=deriveVSchema(models),report=formatShardingReport(decisions),outPath=path.projectPath(options.out??"database/vschema.json");if(!options.dryRun){fs.mkdirSync(dirname(outPath),{recursive:!0});await Bun.write(outPath,`${JSON.stringify(vschema,null,2)}
|
|
2
|
+
`)}return{ok:!0,vschema,report,path:outPath,tableCount:Object.keys(vschema.tables).length}}
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { hasComponents } from "@stacksjs/storage";
|
|
3
|
-
import { generateVsCodeCustomData } from "../helpers/vscode-custom-data";
|
|
4
|
-
log.info("Generating VS Code custom data...");
|
|
5
|
-
if (hasComponents())
|
|
6
|
-
await generateVsCodeCustomData();
|
|
7
|
-
else
|
|
8
|
-
log.info("No components found. Skipping VS Code custom data generation.");
|
|
9
|
-
log.success("Generated VS Code custom data.");
|
|
1
|
+
import{log}from"@stacksjs/logging";import{hasComponents}from"@stacksjs/storage";import{generateVsCodeCustomData}from"../helpers/vscode-custom-data";log.info("Generating VS Code custom data...");if(hasComponents())await generateVsCodeCustomData();else log.info("No components found. Skipping VS Code custom data generation.");log.success("Generated VS Code custom data.");
|
package/dist/helpers/api-host.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
export function resolveApiHost(env
|
|
2
|
-
if (env.API_HOST)
|
|
3
|
-
return env.API_HOST;
|
|
4
|
-
if (env.HOST)
|
|
5
|
-
return env.HOST;
|
|
6
|
-
return env.NODE_ENV === "production" || env.APP_ENV === "production" ? "0.0.0.0" : "127.0.0.1";
|
|
7
|
-
}
|
|
1
|
+
export function resolveApiHost(env=process.env){if(env.API_HOST)return env.API_HOST;if(env.HOST)return env.HOST;return env.NODE_ENV==="production"||env.APP_ENV==="production"?"0.0.0.0":"127.0.0.1"}
|