@bgunnarsson/galdur 1.0.11 → 1.0.14
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/chunk-VAYZNE5T.js +25 -0
- package/dist/chunk-VAYZNE5T.js.map +1 -0
- package/dist/cli.js +5 -14
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +8 -0
- package/package.json +2 -2
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
function isCommand(v) {
|
|
5
|
+
return v === "build" || v === "ssg" || v === "hybrid" || v === "static";
|
|
6
|
+
}
|
|
7
|
+
function getHelpText() {
|
|
8
|
+
return `galdur
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
galdur build Build the app (SSR + client)
|
|
12
|
+
galdur ssg Build the app and render dist/static (hybrid SSG output)
|
|
13
|
+
galdur hybrid Same as ssg, but also builds @bgunnarsson/galdur-ssg in monorepo
|
|
14
|
+
galdur static Build the app and render a fully static dist/static (copies dist/client)
|
|
15
|
+
|
|
16
|
+
Options:
|
|
17
|
+
--insecure Disable TLS certificate validation (for local dev with self-signed certs)
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
isCommand,
|
|
23
|
+
getHelpText
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-VAYZNE5T.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type GaldurCommand = 'build' | 'ssg' | 'hybrid' | 'static'\n\nexport function isCommand(v: string | undefined): v is GaldurCommand {\n return v === 'build' || v === 'ssg' || v === 'hybrid' || v === 'static'\n}\n\nexport function getHelpText(): string {\n return `galdur\n\nUsage:\n galdur build Build the app (SSR + client)\n galdur ssg Build the app and render dist/static (hybrid SSG output)\n galdur hybrid Same as ssg, but also builds @bgunnarsson/galdur-ssg in monorepo\n galdur static Build the app and render a fully static dist/static (copies dist/client)\n\nOptions:\n --insecure Disable TLS certificate validation (for local dev with self-signed certs)\n`\n}\n"],"mappings":";;;AAEO,SAAS,UAAU,GAA2C;AACnE,SAAO,MAAM,WAAW,MAAM,SAAS,MAAM,YAAY,MAAM;AACjE;AAEO,SAAS,cAAsB;AACpC,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWT;","names":[]}
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getHelpText,
|
|
4
|
+
isCommand
|
|
5
|
+
} from "./chunk-VAYZNE5T.js";
|
|
2
6
|
|
|
3
7
|
// src/cli.ts
|
|
4
8
|
import * as fs from "fs";
|
|
@@ -6,9 +10,6 @@ import * as path from "path";
|
|
|
6
10
|
import { spawn } from "child_process";
|
|
7
11
|
import process from "process";
|
|
8
12
|
import { createRequire } from "module";
|
|
9
|
-
function isCommand(v) {
|
|
10
|
-
return v === "build" || v === "ssg" || v === "hybrid" || v === "static";
|
|
11
|
-
}
|
|
12
13
|
function fileExists(p) {
|
|
13
14
|
try {
|
|
14
15
|
return fs.existsSync(p);
|
|
@@ -105,17 +106,7 @@ async function buildApp(appRoot) {
|
|
|
105
106
|
await run(viteBin, ["build", "--config", viteConfig], { cwd: appRoot });
|
|
106
107
|
}
|
|
107
108
|
function printHelp() {
|
|
108
|
-
process.stdout.write(
|
|
109
|
-
|
|
110
|
-
Usage:
|
|
111
|
-
galdur build Build the app (SSR + client)
|
|
112
|
-
galdur ssg Build the app and render dist/static (hybrid SSG output)
|
|
113
|
-
galdur hybrid Same as ssg, but also builds @bgunnarsson/galdur-ssg in monorepo
|
|
114
|
-
galdur static Build the app and render a fully static dist/static (copies dist/client)
|
|
115
|
-
|
|
116
|
-
Options:
|
|
117
|
-
--insecure Disable TLS certificate validation (for local dev with self-signed certs)
|
|
118
|
-
`);
|
|
109
|
+
process.stdout.write(getHelpText());
|
|
119
110
|
}
|
|
120
111
|
async function main() {
|
|
121
112
|
const raw = process.argv.slice(2);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["import * as fs from 'node:fs'\nimport * as path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport process from 'node:process'\nimport { createRequire } from 'node:module'\
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["import * as fs from 'node:fs'\nimport * as path from 'node:path'\nimport { spawn } from 'node:child_process'\nimport process from 'node:process'\nimport { createRequire } from 'node:module'\nimport { isCommand, getHelpText } from './index.js'\n\nfunction fileExists(p: string) {\n try {\n return fs.existsSync(p)\n } catch {\n return false\n }\n}\n\nfunction resolveAppRoot() {\n const cwd = process.cwd()\n const direct = path.resolve(cwd)\n\n const looksLikeAppRoot = (abs: string) => {\n if (fileExists(path.join(abs, 'galdur.config.ts')) || fileExists(path.join(abs, 'galdur.config.js'))) {\n return true\n }\n if (\n fileExists(path.join(abs, 'src', 'app', 'entry.client.tsx')) ||\n fileExists(path.join(abs, 'src', 'app', 'server.ts'))\n ) {\n return true\n }\n return false\n }\n\n // Monorepo workspace root: prefer ./src/app\n if (fileExists(path.join(direct, 'pnpm-workspace.yaml'))) {\n const monorepoApp = path.join(direct, 'src', 'app')\n if (fileExists(path.join(monorepoApp, 'package.json'))) {\n return monorepoApp\n }\n }\n\n // If you're already inside an app, use it.\n if (looksLikeAppRoot(direct)) {\n return direct\n }\n\n // Monorepo default: ./src/app (when executed from a subdir)\n const monorepo = path.resolve(cwd, 'src/app')\n if (fileExists(path.join(monorepo, 'package.json'))) {\n return monorepo\n }\n\n if (fileExists(path.join(direct, 'package.json'))) {\n return direct\n }\n\n return direct\n}\n\nfunction resolveWorkspaceRoot(appRoot: string) {\n const candidate = path.resolve(appRoot, '../..')\n if (fileExists(path.join(candidate, 'pnpm-workspace.yaml'))) {\n return candidate\n }\n return appRoot\n}\n\nfunction run(cmd: string, args: string[], opts: { cwd?: string; env?: NodeJS.ProcessEnv } = {}) {\n return new Promise<void>((resolve, reject) => {\n const child = spawn(cmd, args, {\n stdio: 'inherit',\n cwd: opts.cwd,\n env: opts.env ?? process.env,\n })\n\n child.on('error', reject)\n child.on('exit', (code) => {\n if (code === 0) {\n resolve()\n return\n }\n reject(new Error(`${cmd} ${args.join(' ')} failed with exit code ${code ?? 'null'}`))\n })\n })\n}\n\nfunction resolveSsgCliPath() {\n const req = createRequire(import.meta.url)\n const entry = req.resolve('@bgunnarsson/galdur-ssg')\n return path.join(path.dirname(entry), 'cli.js')\n}\n\nfunction resolveAppBin(appRoot: string, name: string) {\n const bin = path.join(appRoot, 'node_modules', '.bin', name)\n return fileExists(bin) ? bin : null\n}\n\nfunction resolveViteConfig(appRoot: string) {\n const configPath = path.join(appRoot, 'node_modules', '@bgunnarsson', 'galdur-vite', 'vite.config.mjs')\n if (!fileExists(configPath)) {\n throw new Error(`Could not find vite config at ${configPath}. Is @bgunnarsson/galdur-vite installed?`)\n }\n return configPath\n}\n\nasync function buildApp(appRoot: string) {\n const viteBin = resolveAppBin(appRoot, 'vite')\n if (!viteBin) {\n throw new Error('vite not found in app dependencies. Install vite as a devDependency.')\n }\n const viteConfig = resolveViteConfig(appRoot)\n\n // Tailwind (optional) — auto-detected from the app's dependencies\n const twBin = resolveAppBin(appRoot, 'galdur-tailwind')\n const twInput = path.join(appRoot, 'src', 'shared', 'styles', 'main.css')\n if (twBin && fileExists(twInput)) {\n const twOutput = path.join(appRoot, 'public', 'main.min.css')\n process.stdout.write('[galdur] Building Tailwind CSS...\\n')\n await run(twBin, ['--app-root', appRoot, '-i', twInput, '-o', twOutput, '--minify'], { cwd: appRoot })\n }\n\n // SSR build\n process.stdout.write('[galdur] Building server (SSR)...\\n')\n await run(viteBin, ['build', '--ssr', '--config', viteConfig], { cwd: appRoot })\n\n // Client build\n process.stdout.write('[galdur] Building client...\\n')\n await run(viteBin, ['build', '--config', viteConfig], { cwd: appRoot })\n}\n\nfunction printHelp() {\n process.stdout.write(getHelpText())\n}\n\nasync function main() {\n const raw = process.argv.slice(2)\n const cmd = raw[0]\n const insecure = raw.includes('--insecure')\n const passthrough = raw.slice(1).filter((a) => a !== '--insecure')\n\n if (cmd === '--help' || cmd === '-h' || cmd === 'help' || !cmd) {\n printHelp()\n process.exit(cmd ? 0 : 1)\n }\n\n if (!isCommand(cmd)) {\n process.stderr.write(`[galdur] Unknown command: ${cmd}\\n`)\n printHelp()\n process.exit(1)\n }\n\n const appRoot = resolveAppRoot()\n const workspaceRoot = resolveWorkspaceRoot(appRoot)\n\n if (cmd === 'build') {\n await buildApp(appRoot)\n return\n }\n\n // Render SSG output always requires the app build.\n const shouldBuildSsgPkg = cmd === 'hybrid' || cmd === 'static'\n if (shouldBuildSsgPkg && workspaceRoot !== appRoot) {\n await run('pnpm', ['-C', workspaceRoot, '-F', '@bgunnarsson/galdur-ssg', 'build'])\n }\n\n await buildApp(appRoot)\n\n const cliPath = resolveSsgCliPath()\n const outDir = path.join(appRoot, 'dist', 'static')\n const env: NodeJS.ProcessEnv = {\n ...process.env,\n ...(insecure ? { NODE_TLS_REJECT_UNAUTHORIZED: '0' } : {}),\n ...(cmd === 'static' ? { GALDUR_SSG_STATIC: '1' } : {}),\n }\n\n await run(process.execPath, [cliPath, '--app-root', appRoot, '--out-dir', outDir, ...passthrough], { env })\n}\n\nmain().catch((err) => {\n process.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`)\n process.exit(1)\n})\n"],"mappings":";;;;;;;AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,aAAa;AACtB,OAAO,aAAa;AACpB,SAAS,qBAAqB;AAG9B,SAAS,WAAW,GAAW;AAC7B,MAAI;AACF,WAAU,cAAW,CAAC;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,S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ACxD,GAAI,QAAQ,WAAW,EAAE,mBAAmB,IAAI,IAAI,CAAC;AAAA,EACvD;AAEA,QAAM,IAAI,QAAQ,UAAU,CAAC,SAAS,cAAc,SAAS,aAAa,QAAQ,GAAG,WAAW,GAAG,EAAE,IAAI,CAAC;AAC5G;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,CAAI;AAC5E,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["resolve"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bgunnarsson/galdur",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Galdur SSR-First React Framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@bgunnarsson/galdur-ssg": "1.0.
|
|
23
|
+
"@bgunnarsson/galdur-ssg": "1.0.14"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "24.10.1",
|