wyvrnpm 2.10.2 → 2.12.2

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.
Files changed (49) hide show
  1. package/README.md +1914 -1860
  2. package/bin/{wyvrn.js → wyvrnpm.js} +66 -0
  3. package/cmake/cpp.cmake +9 -9
  4. package/cmake/functions.cmake +224 -224
  5. package/cmake/macros.cmake +284 -284
  6. package/package.json +3 -2
  7. package/src/auth.js +66 -66
  8. package/src/binary-dir.js +95 -0
  9. package/src/bootstrap/cookbook.js +196 -196
  10. package/src/bootstrap/detect.js +150 -150
  11. package/src/bootstrap/index.js +220 -220
  12. package/src/bootstrap/version.js +72 -72
  13. package/src/build/cache.js +344 -344
  14. package/src/build/clone.js +170 -170
  15. package/src/build/cmake.js +342 -342
  16. package/src/build/index.js +299 -297
  17. package/src/build/msvc-env.js +260 -260
  18. package/src/build/recipe.js +188 -188
  19. package/src/commands/add.js +141 -141
  20. package/src/commands/bootstrap.js +96 -96
  21. package/src/commands/build.js +482 -452
  22. package/src/commands/cache.js +189 -189
  23. package/src/commands/clean.js +80 -80
  24. package/src/commands/configure.js +92 -92
  25. package/src/commands/init.js +70 -70
  26. package/src/commands/install-skill.js +115 -115
  27. package/src/commands/install.js +730 -674
  28. package/src/commands/link.js +320 -320
  29. package/src/commands/profile.js +237 -237
  30. package/src/commands/publish.js +584 -555
  31. package/src/commands/show.js +252 -252
  32. package/src/commands/version.js +187 -0
  33. package/src/compat.js +273 -273
  34. package/src/conf/index.js +415 -391
  35. package/src/conf/namespaces.js +94 -94
  36. package/src/context.js +230 -230
  37. package/src/http-fetch.js +53 -53
  38. package/src/ignore.js +118 -118
  39. package/src/logger.js +122 -122
  40. package/src/options.js +303 -303
  41. package/src/settings-overrides.js +152 -152
  42. package/src/toolchain/deps.js +164 -164
  43. package/src/toolchain/index.js +212 -212
  44. package/src/toolchain/presets.js +356 -340
  45. package/src/toolchain/template.cmake +77 -77
  46. package/src/upload-built.js +265 -265
  47. package/src/version-range.js +301 -301
  48. package/src/zip-safe.js +52 -52
  49. package/src/zip-stream.js +126 -0
@@ -0,0 +1,187 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+
5
+ const { readManifest, writeManifest } = require('../manifest');
6
+ const log = require('../logger');
7
+
8
+ /** Strict 4-part wyvrnpm version: `x.y.z.b`, all non-negative integers, no leading zeros. */
9
+ const VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
10
+
11
+ /**
12
+ * Parse a 4-part version string into `[major, minor, patch, build]`.
13
+ * Throws with a clear message when the string fails the wyvrnpm format.
14
+ *
15
+ * @param {string} v
16
+ * @returns {[number, number, number, number]}
17
+ */
18
+ function parseVersion(v) {
19
+ if (typeof v !== 'string' || v.length === 0) {
20
+ throw new Error('version is empty');
21
+ }
22
+ const m = VERSION_RE.exec(v);
23
+ if (!m) {
24
+ throw new Error(
25
+ `"${v}" is not a valid wyvrnpm version. ` +
26
+ 'Expected 4-part x.y.z.b with non-negative integers (e.g. 1.2.3.4).',
27
+ );
28
+ }
29
+ return [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])];
30
+ }
31
+
32
+ const COMPONENT_INDEX = { major: 0, minor: 1, patch: 2, build: 3 };
33
+
34
+ function isNonNegInt(n) {
35
+ return Number.isInteger(n) && n >= 0;
36
+ }
37
+
38
+ /**
39
+ * `wyvrnpm version [<new-version>]` — read, set, or partially update the
40
+ * top-level `version` field in wyvrn.json. Designed for CI/CD (build-number
41
+ * injection + tag-the-build readback).
42
+ *
43
+ * wyvrnpm version → print the current version
44
+ * wyvrnpm version 1.2.3.4 → set verbatim
45
+ * wyvrnpm version --build 99 → only the 4th component
46
+ * wyvrnpm version --minor 3 --build 0 → multiple components, others left alone
47
+ *
48
+ * Positional and component flags are mutually exclusive — pick one mode.
49
+ * Bare invocation is read-only (never writes, never warns about an unset
50
+ * version on disk — it prints `(unset)` to stderr and exits 1 in that
51
+ * case so scripts notice). CI scripts use --format json to capture the
52
+ * `{ previous, version }` payload on stdout.
53
+ *
54
+ * @param {object} argv
55
+ */
56
+ function versionCmd(argv) {
57
+ const manifestPath = path.resolve(argv.manifest);
58
+ const jsonOut = argv.format === 'json';
59
+ if (jsonOut) log.setJsonMode(true);
60
+
61
+ const positional = argv.newVersion;
62
+
63
+ // Component flags arrive on argv as `argv.major` / `argv.minor` / etc.
64
+ // because yargs lowercases option names. Keep insertion order so error
65
+ // messages list flags in the same order as the CLI surface.
66
+ const partial = {};
67
+ for (const key of Object.keys(COMPONENT_INDEX)) {
68
+ if (argv[key] !== undefined) partial[key] = argv[key];
69
+ }
70
+ const partialKeys = Object.keys(partial);
71
+
72
+ if (positional && partialKeys.length > 0) {
73
+ log.error(
74
+ 'cannot combine a positional version with --major/--minor/--patch/--build. ' +
75
+ 'Use one or the other.',
76
+ );
77
+ process.exit(1);
78
+ }
79
+
80
+ // Read-only mode: no positional + no component flags. Prints the current
81
+ // version and returns without touching disk. Matches `npm version` behaviour
82
+ // when called bare.
83
+ const readOnly = !positional && partialKeys.length === 0;
84
+
85
+ let manifest;
86
+ try {
87
+ manifest = readManifest(manifestPath);
88
+ } catch (err) {
89
+ log.error(err.message);
90
+ process.exit(1);
91
+ }
92
+
93
+ const previous =
94
+ typeof manifest.version === 'string' && manifest.version.length > 0
95
+ ? manifest.version
96
+ : null;
97
+
98
+ if (readOnly) {
99
+ const wyvrnpmVersion = require('../../package.json').version;
100
+ if (jsonOut) {
101
+ process.stdout.write(JSON.stringify({
102
+ command: 'version',
103
+ wyvrnpmVersion,
104
+ path: manifestPath,
105
+ version: previous,
106
+ written: false,
107
+ }) + '\n');
108
+ } else if (previous) {
109
+ // Bare stdout for `VER=$(wyvrnpm version)` — no `[wyvrn]` prefix here.
110
+ process.stdout.write(previous + '\n');
111
+ } else {
112
+ log.error(`no \`version\` field in ${manifestPath}`);
113
+ process.exit(1);
114
+ }
115
+ return;
116
+ }
117
+
118
+ let newVersion;
119
+ if (positional) {
120
+ try {
121
+ parseVersion(positional);
122
+ } catch (err) {
123
+ log.error(err.message);
124
+ process.exit(1);
125
+ }
126
+ newVersion = positional;
127
+ } else {
128
+ let parts;
129
+ try {
130
+ parts = parseVersion(previous ?? '');
131
+ } catch (err) {
132
+ log.error(
133
+ `cannot tweak components — current manifest version is invalid or missing: ${err.message}\n` +
134
+ ' Set a full version first: wyvrnpm version <x.y.z.b>',
135
+ );
136
+ process.exit(1);
137
+ }
138
+ for (const key of partialKeys) {
139
+ const n = partial[key];
140
+ if (!isNonNegInt(n)) {
141
+ log.error(`--${key} must be a non-negative integer (got ${JSON.stringify(n)})`);
142
+ process.exit(1);
143
+ }
144
+ parts[COMPONENT_INDEX[key]] = n;
145
+ }
146
+ newVersion = parts.join('.');
147
+ }
148
+
149
+ const wyvrnpmVersion = require('../../package.json').version;
150
+
151
+ if (argv.dryRun) {
152
+ if (jsonOut) {
153
+ process.stdout.write(JSON.stringify({
154
+ command: 'version',
155
+ wyvrnpmVersion,
156
+ path: manifestPath,
157
+ previous,
158
+ version: newVersion,
159
+ dryRun: true,
160
+ written: false,
161
+ }) + '\n');
162
+ } else {
163
+ log.info(`would set version: ${previous ?? '(unset)'} → ${newVersion} (dry-run)`);
164
+ }
165
+ return;
166
+ }
167
+
168
+ manifest.version = newVersion;
169
+ writeManifest(manifestPath, manifest);
170
+
171
+ if (jsonOut) {
172
+ process.stdout.write(JSON.stringify({
173
+ command: 'version',
174
+ wyvrnpmVersion,
175
+ path: manifestPath,
176
+ previous,
177
+ version: newVersion,
178
+ dryRun: false,
179
+ written: true,
180
+ }) + '\n');
181
+ } else {
182
+ log.success(`${manifestPath}: ${previous ?? '(unset)'} → ${newVersion}`);
183
+ }
184
+ }
185
+
186
+ module.exports = versionCmd;
187
+ module.exports.parseVersion = parseVersion;