zudojs-cli 1.0.0 → 1.1.1
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/README.md +16 -6
- package/dist/src/adapters/frontend/frontendAdapter.type.d.ts +6 -0
- package/dist/src/bin/zudojs.js +8 -32
- package/dist/src/cliApplication/cliApplication.core.js +2 -2
- package/dist/src/cliApplication/cliApplication.logger.d.ts +28 -0
- package/dist/src/cliApplication/cliApplication.logger.js +68 -0
- package/dist/src/cliApplication/index.d.ts +1 -3
- package/dist/src/cliApplication/index.js +1 -3
- package/dist/src/cliVersion/cliVersion.update.d.ts +38 -0
- package/dist/src/cliVersion/cliVersion.update.js +63 -0
- package/dist/src/cliVersion/index.d.ts +2 -1
- package/dist/src/cliVersion/index.js +2 -1
- package/dist/src/commands/add.command.d.ts +29 -0
- package/dist/src/commands/add.command.js +94 -109
- package/dist/src/commands/build.command.d.ts +8 -0
- package/dist/src/commands/build.command.js +12 -18
- package/dist/src/commands/create.command.js +8 -5
- package/dist/src/commands/dev.command.d.ts +30 -2
- package/dist/src/commands/dev.command.js +104 -183
- package/dist/src/commands/doctor.command.d.ts +18 -0
- package/dist/src/commands/doctor.command.js +141 -113
- package/dist/src/commands/generate.command.d.ts +2 -1
- package/dist/src/commands/generate.command.js +23 -42
- package/dist/src/commands/info.command.js +61 -30
- package/dist/src/constants/index.d.ts +18 -2
- package/dist/src/constants/index.js +31 -2
- package/dist/src/generators/frontend/frontendGenerator.core.d.ts +2 -0
- package/dist/src/generators/frontend/frontendGenerator.core.js +11 -0
- package/dist/src/generators/frontend/frontendPipeline.js +45 -2
- package/dist/src/generators/fullstack/fullstackComposer.core.d.ts +2 -0
- package/dist/src/generators/fullstack/fullstackComposer.core.js +8 -22
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.js +3 -2
- package/dist/src/installers/dependency.installer.d.ts +9 -0
- package/dist/src/installers/dependency.installer.js +21 -0
- package/dist/src/installers/index.d.ts +1 -3
- package/dist/src/installers/index.js +1 -3
- package/dist/src/resolvers/architecture.resolver.d.ts +11 -1
- package/dist/src/resolvers/architecture.resolver.js +12 -13
- package/dist/src/resolvers/configuration/configurationResolver.core.d.ts +10 -1
- package/dist/src/resolvers/configuration/configurationResolver.core.js +68 -29
- package/dist/src/resolvers/index.d.ts +1 -0
- package/dist/src/resolvers/index.js +1 -0
- package/dist/src/resolvers/layout/index.d.ts +5 -0
- package/dist/src/resolvers/layout/index.js +5 -0
- package/dist/src/resolvers/layout/projectLayout.core.d.ts +60 -0
- package/dist/src/resolvers/layout/projectLayout.core.js +236 -0
- package/dist/src/resolvers/project.resolver.d.ts +5 -0
- package/dist/src/resolvers/project.resolver.js +10 -6
- package/dist/src/templates/microservice/microservice.template.d.ts +0 -1
- package/dist/src/templates/microservice/microservice.template.js +2 -10
- package/dist/src/templates/modular-monolith/modularMonolith.template.d.ts +0 -1
- package/dist/src/templates/modular-monolith/modularMonolith.template.js +4 -7
- package/dist/src/templates/monolith/monolith.template.d.ts +0 -1
- package/dist/src/templates/monolith/monolith.template.js +4 -7
- package/dist/src/templates/shared/appRuntime.template.d.ts +0 -11
- package/dist/src/templates/shared/appRuntime.template.js +0 -20
- package/dist/src/templates/shared/index.d.ts +1 -0
- package/dist/src/templates/shared/index.js +1 -0
- package/dist/src/templates/shared/pnpm.template.d.ts +27 -0
- package/dist/src/templates/shared/pnpm.template.js +57 -0
- package/dist/src/utils/utils.detect.d.ts +9 -0
- package/dist/src/utils/utils.detect.js +11 -11
- package/dist/src/utils/utils.exec.d.ts +17 -1
- package/dist/src/utils/utils.exec.js +65 -4
- package/package.json +12 -10
- package/dist/src/scripts/postinstall.cjs +0 -77
- package/src/scripts/postinstall.cjs +0 -77
package/README.md
CHANGED
|
@@ -59,11 +59,21 @@ zudojs build
|
|
|
59
59
|
`zudojs build` and `zudojs doctor` exit with a non-zero status when they fail,
|
|
60
60
|
so they can be used as CI gates.
|
|
61
61
|
|
|
62
|
-
###
|
|
62
|
+
### Update check
|
|
63
63
|
|
|
64
|
-
`zudojs
|
|
65
|
-
`ZUDOJS_NO_UPDATE_CHECK=1` to turn it off; it is skipped
|
|
66
|
-
`CI` is set
|
|
64
|
+
`zudojs info` asks npm whether a newer `zudojs-cli` exists and prints the
|
|
65
|
+
version if so. Set `ZUDOJS_NO_UPDATE_CHECK=1` to turn it off; it is skipped
|
|
66
|
+
automatically when `CI` is set or npm is offline. Nothing runs at install
|
|
67
|
+
time.
|
|
68
|
+
|
|
69
|
+
### What a new project contains
|
|
70
|
+
|
|
71
|
+
`zudojs create` records the project's type, architecture, package manager and
|
|
72
|
+
capabilities in `.zudojs/manifest.json` (machine-managed) and in the `zudojs`
|
|
73
|
+
block of `package.json`. Every follow-up command reads those; no
|
|
74
|
+
`zudojs.config.ts` is written. Framework packages are added as `^1.0.0`
|
|
75
|
+
ranges, and projects created for pnpm carry a `pnpm-workspace.yaml` that
|
|
76
|
+
allows esbuild's build script, which pnpm 10+ would otherwise refuse to run.
|
|
67
77
|
|
|
68
78
|
## Commands
|
|
69
79
|
|
|
@@ -71,8 +81,8 @@ so they can be used as CI gates.
|
|
|
71
81
|
| ---------- | ------------------------------------------------------------------------ |
|
|
72
82
|
| `create` | Scaffold a new project (backend, frontend, or fullstack) |
|
|
73
83
|
| `generate` | Generate files (service, module, command, query, controller, repository) |
|
|
74
|
-
| `add` | Add feature packages (database, queue, messaging, etc.)
|
|
75
|
-
| `dev` | Start development servers
|
|
84
|
+
| `add` | Add feature packages (database, queue, messaging, etc.); `--service` targets one microservice app |
|
|
85
|
+
| `dev` | Start development servers through the project's package manager (`pnpm run dev`, …) |
|
|
76
86
|
| `build` | Build the project with its detected package manager |
|
|
77
87
|
| `doctor` | Run project diagnostics |
|
|
78
88
|
| `info` | Show project information |
|
|
@@ -17,6 +17,12 @@ export interface FrontendGenerationContext {
|
|
|
17
17
|
readonly architecture: "zudojs-standard" | "feature-based" | "minimal" | "framework-default";
|
|
18
18
|
readonly packageManager: "pnpm" | "npm" | "yarn" | "bun";
|
|
19
19
|
readonly features: FrontendFeatures;
|
|
20
|
+
/**
|
|
21
|
+
* Record resolved dependencies in package.json instead of installing
|
|
22
|
+
* them. Set by `zudojs create --no-install`, which the frontend pipeline
|
|
23
|
+
* used to ignore: it ran the package manager regardless of the flag.
|
|
24
|
+
*/
|
|
25
|
+
readonly skipInstall?: boolean;
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
28
|
* Optional frontend features.
|
package/dist/src/bin/zudojs.js
CHANGED
|
@@ -4,12 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module bin/zudojs
|
|
6
6
|
*/
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
8
|
-
import { dirname, join } from "node:path";
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
10
7
|
import { createCLI } from "../cliApplication/index.js";
|
|
11
|
-
import { CLI_DEFAULTS } from "../cliConstant/cliConstant.value.js";
|
|
12
8
|
import { createCommand } from "../cliCommand/index.js";
|
|
9
|
+
import { CLI_VERSION, FEATURE_PACKAGES } from "../constants/index.js";
|
|
13
10
|
import { runCreateCommand } from "../commands/create.command.js";
|
|
14
11
|
import { runDevCommand } from "../commands/dev.command.js";
|
|
15
12
|
import { runGenerateCommand } from "../commands/generate.command.js";
|
|
@@ -17,32 +14,11 @@ import { runAddCommand } from "../commands/add.command.js";
|
|
|
17
14
|
import { runBuildCommand } from "../commands/build.command.js";
|
|
18
15
|
import { runDoctorCommand } from "../commands/doctor.command.js";
|
|
19
16
|
import { runInfoCommand } from "../commands/info.command.js";
|
|
20
|
-
/**
|
|
21
|
-
* Reads the CLI's real version from its own package.json at runtime so
|
|
22
|
-
* `zudojs --version` can never drift from the published version.
|
|
23
|
-
*/
|
|
24
|
-
function readCliVersion() {
|
|
25
|
-
let dir = dirname(fileURLToPath(import.meta.url));
|
|
26
|
-
for (let depth = 0; depth < 6; depth++) {
|
|
27
|
-
try {
|
|
28
|
-
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf-8"));
|
|
29
|
-
if (pkg.name === "zudojs-cli" && pkg.version) {
|
|
30
|
-
return pkg.version;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
// keep walking up
|
|
35
|
-
}
|
|
36
|
-
const parent = dirname(dir);
|
|
37
|
-
if (parent === dir)
|
|
38
|
-
break;
|
|
39
|
-
dir = parent;
|
|
40
|
-
}
|
|
41
|
-
return CLI_DEFAULTS.VERSION;
|
|
42
|
-
}
|
|
43
17
|
const app = createCLI({
|
|
44
18
|
name: "Zudojs",
|
|
45
|
-
version
|
|
19
|
+
// Read from the CLI's own package.json, so `zudojs --version` cannot
|
|
20
|
+
// drift from the published version.
|
|
21
|
+
version: CLI_VERSION,
|
|
46
22
|
description: "Command-line interface for the Zudojs framework.",
|
|
47
23
|
});
|
|
48
24
|
app.register(createCommand({
|
|
@@ -211,15 +187,15 @@ app.register(createCommand({
|
|
|
211
187
|
arguments: [
|
|
212
188
|
{
|
|
213
189
|
name: "feature",
|
|
214
|
-
description:
|
|
190
|
+
description: `The feature to add (${Object.keys(FEATURE_PACKAGES).join(", ")})`,
|
|
215
191
|
required: true,
|
|
216
192
|
},
|
|
217
193
|
],
|
|
218
194
|
options: [
|
|
219
195
|
{
|
|
220
|
-
name: "
|
|
221
|
-
short: "
|
|
222
|
-
description: "
|
|
196
|
+
name: "service",
|
|
197
|
+
short: "s",
|
|
198
|
+
description: "Add the feature to one app of a microservice project (gateway or a service name)",
|
|
223
199
|
type: "string",
|
|
224
200
|
},
|
|
225
201
|
{
|
|
@@ -10,8 +10,8 @@ import { CommandNotFoundError } from "../cliError/cliError.command.js";
|
|
|
10
10
|
import { CLICommandRegistry } from "../cliCommand/cliCommand.registry.js";
|
|
11
11
|
import { executeCommand } from "../cliCommand/cliCommand.factory.js";
|
|
12
12
|
import { CLIParser, resolveCommand } from "../cliParser/index.js";
|
|
13
|
-
import { createDefaultLogger } from "@zudojs/logger";
|
|
14
13
|
import { createCLIWriter } from "./cliApplication.writer.js";
|
|
14
|
+
import { createCLILogger } from "./cliApplication.logger.js";
|
|
15
15
|
import { isHelpRequest, isVersionRequest, printVersion, printHelp, } from "./cliApplication.builtins.js";
|
|
16
16
|
/* -------------------------------------------------------------------------- */
|
|
17
17
|
/* Application */
|
|
@@ -38,7 +38,7 @@ export class ZudojsCLI {
|
|
|
38
38
|
this.description = options.description ?? CLI_DEFAULTS.DESCRIPTION;
|
|
39
39
|
this.cwd = options.cwd ?? process.cwd();
|
|
40
40
|
this.env = options.env ?? process.env;
|
|
41
|
-
this.logger = options.logger ??
|
|
41
|
+
this.logger = options.logger ?? createCLILogger();
|
|
42
42
|
this.commands = new CLICommandRegistry();
|
|
43
43
|
this.parser = new CLIParser();
|
|
44
44
|
this.writer = createCLIWriter();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zudojs-cli — CLI Logger
|
|
3
|
+
*
|
|
4
|
+
* A `Logger` whose output is plain terminal text.
|
|
5
|
+
*
|
|
6
|
+
* The CLI used `createDefaultLogger()` from `@zudojs/logger`, whose console
|
|
7
|
+
* transport prints the whole serialised log record. Every line a command
|
|
8
|
+
* wrote to the user came out as a multi-line object literal with a
|
|
9
|
+
* timestamp, a level, a logger name and an empty metadata block wrapped
|
|
10
|
+
* around the message. This logger keeps the `Logger` contract (commands
|
|
11
|
+
* still receive `context.logger`) and writes one line per call: info to
|
|
12
|
+
* stdout, warnings and errors to stderr.
|
|
13
|
+
*
|
|
14
|
+
* @module cliApplication/logger
|
|
15
|
+
*/
|
|
16
|
+
import { type Logger, type LoggerEntry } from "@zudojs/logger";
|
|
17
|
+
export interface CLILoggerOptions {
|
|
18
|
+
/** Emit debug and trace lines too. Defaults to `ZUDOJS_DEBUG` being set. */
|
|
19
|
+
readonly verbose?: boolean;
|
|
20
|
+
/** Line writers, overridable for tests. */
|
|
21
|
+
readonly stdout?: (line: string) => void;
|
|
22
|
+
readonly stderr?: (line: string) => void;
|
|
23
|
+
}
|
|
24
|
+
/** Renders one entry as the single line the user sees. */
|
|
25
|
+
export declare function formatCLILogLine(entry: LoggerEntry): string;
|
|
26
|
+
/** Creates the logger handed to every command as `context.logger`. */
|
|
27
|
+
export declare function createCLILogger(options?: CLILoggerOptions): Logger;
|
|
28
|
+
//# sourceMappingURL=cliApplication.logger.d.ts.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zudojs-cli — CLI Logger
|
|
3
|
+
*
|
|
4
|
+
* A `Logger` whose output is plain terminal text.
|
|
5
|
+
*
|
|
6
|
+
* The CLI used `createDefaultLogger()` from `@zudojs/logger`, whose console
|
|
7
|
+
* transport prints the whole serialised log record. Every line a command
|
|
8
|
+
* wrote to the user came out as a multi-line object literal with a
|
|
9
|
+
* timestamp, a level, a logger name and an empty metadata block wrapped
|
|
10
|
+
* around the message. This logger keeps the `Logger` contract (commands
|
|
11
|
+
* still receive `context.logger`) and writes one line per call: info to
|
|
12
|
+
* stdout, warnings and errors to stderr.
|
|
13
|
+
*
|
|
14
|
+
* @module cliApplication/logger
|
|
15
|
+
*/
|
|
16
|
+
import { createLogger, LoggerLevel, } from "@zudojs/logger";
|
|
17
|
+
/** Renders one entry as the single line the user sees. */
|
|
18
|
+
export function formatCLILogLine(entry) {
|
|
19
|
+
switch (entry.levelName) {
|
|
20
|
+
case "fatal":
|
|
21
|
+
case "error":
|
|
22
|
+
return `Error: ${entry.message}`;
|
|
23
|
+
case "warn":
|
|
24
|
+
return `Warning: ${entry.message}`;
|
|
25
|
+
case "debug":
|
|
26
|
+
case "trace":
|
|
27
|
+
return `[${entry.levelName}] ${entry.message}`;
|
|
28
|
+
default:
|
|
29
|
+
return entry.message;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Creates the logger handed to every command as `context.logger`. */
|
|
33
|
+
export function createCLILogger(options = {}) {
|
|
34
|
+
const verbose = options.verbose ??
|
|
35
|
+
(process.env["ZUDOJS_DEBUG"] !== undefined &&
|
|
36
|
+
process.env["ZUDOJS_DEBUG"] !== "" &&
|
|
37
|
+
process.env["ZUDOJS_DEBUG"] !== "0");
|
|
38
|
+
const stdout = options.stdout ?? ((line) => process.stdout.write(`${line}\n`));
|
|
39
|
+
const stderr = options.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
40
|
+
return createLogger({
|
|
41
|
+
name: "zudojs",
|
|
42
|
+
level: verbose ? LoggerLevel.TRACE : LoggerLevel.INFO,
|
|
43
|
+
// Writes must complete before a command returns; `process.exit` follows
|
|
44
|
+
// an error immediately.
|
|
45
|
+
asynchronous: false,
|
|
46
|
+
formatter: (entry) => formatCLILogLine(entry),
|
|
47
|
+
transports: [
|
|
48
|
+
{
|
|
49
|
+
name: "cli-stdio",
|
|
50
|
+
enabled: true,
|
|
51
|
+
write(entry) {
|
|
52
|
+
// The formatter's output arrives as the entry message.
|
|
53
|
+
const line = entry.message;
|
|
54
|
+
switch (entry.levelName) {
|
|
55
|
+
case "fatal":
|
|
56
|
+
case "error":
|
|
57
|
+
case "warn":
|
|
58
|
+
stderr(line);
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
stdout(line);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=cliApplication.logger.js.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* zudojs-cli — CLI Application
|
|
3
|
-
*
|
|
4
|
-
* Main application class, factory, built-in commands, and signal handling.
|
|
5
3
|
*/
|
|
6
4
|
export { ZudojsCLI, createCLI } from "./cliApplication.core.js";
|
|
7
5
|
export { createCLIWriter, registerCLIInterruptHandler, } from "./cliApplication.writer.js";
|
|
8
|
-
export {
|
|
6
|
+
export { createCLILogger, formatCLILogLine, type CLILoggerOptions, } from "./cliApplication.logger.js";
|
|
9
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* zudojs-cli — CLI Application
|
|
3
|
-
*
|
|
4
|
-
* Main application class, factory, built-in commands, and signal handling.
|
|
5
3
|
*/
|
|
6
4
|
export { ZudojsCLI, createCLI } from "./cliApplication.core.js";
|
|
7
5
|
export { createCLIWriter, registerCLIInterruptHandler, } from "./cliApplication.writer.js";
|
|
8
|
-
export {
|
|
6
|
+
export { createCLILogger, formatCLILogLine, } from "./cliApplication.logger.js";
|
|
9
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zudojs-cli — Update check
|
|
3
|
+
*
|
|
4
|
+
* Asks the npm registry whether a newer `zudojs-cli` exists.
|
|
5
|
+
*
|
|
6
|
+
* This used to run as a `postinstall` script. npm 11 and pnpm 10 no longer
|
|
7
|
+
* run install scripts of freshly added packages without explicit approval,
|
|
8
|
+
* so the check was skipped with a warning on every install and, worse, the
|
|
9
|
+
* warning made the CLI look broken before it had run once. The check now
|
|
10
|
+
* runs on demand from `zudojs info`, where a network round-trip is expected.
|
|
11
|
+
*
|
|
12
|
+
* @module cliVersion/update
|
|
13
|
+
*/
|
|
14
|
+
export interface UpdateCheckOptions {
|
|
15
|
+
/** Milliseconds to wait for the registry before giving up. */
|
|
16
|
+
readonly timeoutMs?: number;
|
|
17
|
+
readonly registryUrl?: string;
|
|
18
|
+
readonly packageName?: string;
|
|
19
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
20
|
+
readonly fetchImpl?: typeof fetch;
|
|
21
|
+
}
|
|
22
|
+
export interface UpdateCheckResult {
|
|
23
|
+
readonly current: string;
|
|
24
|
+
/** The newer published version, or `null` when up to date or unknown. */
|
|
25
|
+
readonly latest: string | null;
|
|
26
|
+
/** Why no answer was obtained, when `latest` is `null`. */
|
|
27
|
+
readonly skipped?: "disabled" | "offline" | "unavailable";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Whether the update check is turned off for this environment.
|
|
31
|
+
*
|
|
32
|
+
* `ZUDOJS_NO_UPDATE_CHECK` disables it explicitly; `CI` and npm's offline
|
|
33
|
+
* mode disable it implicitly.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isUpdateCheckDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
36
|
+
/** Looks up the latest published version and compares it with `current`. */
|
|
37
|
+
export declare function checkForNewerVersion(current: string, options?: UpdateCheckOptions): Promise<UpdateCheckResult>;
|
|
38
|
+
//# sourceMappingURL=cliVersion.update.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zudojs-cli — Update check
|
|
3
|
+
*
|
|
4
|
+
* Asks the npm registry whether a newer `zudojs-cli` exists.
|
|
5
|
+
*
|
|
6
|
+
* This used to run as a `postinstall` script. npm 11 and pnpm 10 no longer
|
|
7
|
+
* run install scripts of freshly added packages without explicit approval,
|
|
8
|
+
* so the check was skipped with a warning on every install and, worse, the
|
|
9
|
+
* warning made the CLI look broken before it had run once. The check now
|
|
10
|
+
* runs on demand from `zudojs info`, where a network round-trip is expected.
|
|
11
|
+
*
|
|
12
|
+
* @module cliVersion/update
|
|
13
|
+
*/
|
|
14
|
+
import { compareVersions, isValidVersion } from "./cliVersion.core.js";
|
|
15
|
+
/**
|
|
16
|
+
* Whether the update check is turned off for this environment.
|
|
17
|
+
*
|
|
18
|
+
* `ZUDOJS_NO_UPDATE_CHECK` disables it explicitly; `CI` and npm's offline
|
|
19
|
+
* mode disable it implicitly.
|
|
20
|
+
*/
|
|
21
|
+
export function isUpdateCheckDisabled(env = process.env) {
|
|
22
|
+
const flag = env["ZUDOJS_NO_UPDATE_CHECK"];
|
|
23
|
+
if (flag !== undefined && flag !== "" && flag !== "0")
|
|
24
|
+
return true;
|
|
25
|
+
if (env["CI"] !== undefined && env["CI"] !== "" && env["CI"] !== "false")
|
|
26
|
+
return true;
|
|
27
|
+
if (env["npm_config_offline"] === "true")
|
|
28
|
+
return true;
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
/** Looks up the latest published version and compares it with `current`. */
|
|
32
|
+
export async function checkForNewerVersion(current, options = {}) {
|
|
33
|
+
if (isUpdateCheckDisabled(options.env)) {
|
|
34
|
+
return { current, latest: null, skipped: "disabled" };
|
|
35
|
+
}
|
|
36
|
+
const packageName = options.packageName ?? "zudojs-cli";
|
|
37
|
+
const registryUrl = options.registryUrl ?? "https://registry.npmjs.org";
|
|
38
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? 3000);
|
|
41
|
+
try {
|
|
42
|
+
const response = await fetchImpl(`${registryUrl}/${encodeURIComponent(packageName)}/latest`, { signal: controller.signal });
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
return { current, latest: null, skipped: "unavailable" };
|
|
45
|
+
}
|
|
46
|
+
const data = (await response.json());
|
|
47
|
+
const latest = typeof data.version === "string" ? data.version : null;
|
|
48
|
+
if (latest === null ||
|
|
49
|
+
!isValidVersion(latest) ||
|
|
50
|
+
!isValidVersion(current) ||
|
|
51
|
+
compareVersions(latest, current) <= 0) {
|
|
52
|
+
return { current, latest: null };
|
|
53
|
+
}
|
|
54
|
+
return { current, latest };
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return { current, latest: null, skipped: "offline" };
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=cliVersion.update.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* zudojs-cli — CLI Version
|
|
3
3
|
*
|
|
4
|
-
* Semantic version parsing, comparison, and
|
|
4
|
+
* Semantic version parsing, comparison, formatting, and the update check.
|
|
5
5
|
*/
|
|
6
6
|
export { getCLIVersion, formatCLIVersion, getVersionString, isValidVersion, compareVersions, parseVersion, isCompatibleVersion, type CLIVersionInfo, } from "./cliVersion.core.js";
|
|
7
|
+
export { checkForNewerVersion, isUpdateCheckDisabled, type UpdateCheckOptions, type UpdateCheckResult, } from "./cliVersion.update.js";
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* zudojs-cli — CLI Version
|
|
3
3
|
*
|
|
4
|
-
* Semantic version parsing, comparison, and
|
|
4
|
+
* Semantic version parsing, comparison, formatting, and the update check.
|
|
5
5
|
*/
|
|
6
6
|
export { getCLIVersion, formatCLIVersion, getVersionString, isValidVersion, compareVersions, parseVersion, isCompatibleVersion, } from "./cliVersion.core.js";
|
|
7
|
+
export { checkForNewerVersion, isUpdateCheckDisabled, } from "./cliVersion.update.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -4,5 +4,34 @@
|
|
|
4
4
|
* The `zudojs add` command for adding feature packages.
|
|
5
5
|
*/
|
|
6
6
|
import type { CLIContext } from "../cliType/cliType.type.js";
|
|
7
|
+
import { type ProjectLayout } from "../resolvers/layout/projectLayout.core.js";
|
|
8
|
+
interface PackageJsonShape {
|
|
9
|
+
dependencies?: Record<string, string>;
|
|
10
|
+
devDependencies?: Record<string, string>;
|
|
11
|
+
zudojs?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Picks the `package.json` files a feature is added to.
|
|
15
|
+
*
|
|
16
|
+
* The workspace root used to be the only target. In a fullstack project
|
|
17
|
+
* that root holds no application code, so `@zudojs/database` landed where
|
|
18
|
+
* nothing could import it while `apps/api` stayed without it. Features now
|
|
19
|
+
* go to every backend app (`apps/api`, or the gateway and each service of a
|
|
20
|
+
* microservice project); `--service <name>` narrows a microservice project
|
|
21
|
+
* to one app.
|
|
22
|
+
*/
|
|
23
|
+
export declare function selectAddTargets(layout: ProjectLayout, service: string | undefined): string[];
|
|
24
|
+
/**
|
|
25
|
+
* The version written for a new `@zudojs/*` dependency.
|
|
26
|
+
*
|
|
27
|
+
* `workspace:*` was written whenever the project was a workspace. Every
|
|
28
|
+
* generated fullstack and microservice project is a workspace, and none of
|
|
29
|
+
* them contains the framework packages, so the next install failed with
|
|
30
|
+
* "not found in workspace". The protocol is now used only when the target
|
|
31
|
+
* already links a framework package that way — i.e. inside the Zudojs
|
|
32
|
+
* monorepo itself.
|
|
33
|
+
*/
|
|
34
|
+
export declare function versionForNewDependency(pkg: PackageJsonShape): string;
|
|
7
35
|
export declare function runAddCommand(context: CLIContext): Promise<void>;
|
|
36
|
+
export {};
|
|
8
37
|
//# sourceMappingURL=add.command.d.ts.map
|