wyvrnpm 1.2.0 → 1.3.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.
@@ -1,80 +1,80 @@
1
- 'use strict';
2
-
3
- const { readConfig, writeConfig, getConfigPath } = require('../config');
4
-
5
- /** wyvrnpm configure list */
6
- function list() {
7
- const config = readConfig();
8
-
9
- console.log(`Config: ${getConfigPath()}\n`);
10
-
11
- printSection('Install Sources', config.installSources);
12
- console.log('');
13
- printSection('Publish Sources', config.publishSources);
14
- }
15
-
16
- function printSection(title, sources) {
17
- console.log(`${title}:`);
18
- if (sources.length === 0) {
19
- console.log(' (none)');
20
- return;
21
- }
22
- for (const src of sources) {
23
- const auth = authLabel(src);
24
- console.log(` ${src.name.padEnd(20)} ${src.url}${auth ? ' ' + auth : ''}`);
25
- }
26
- }
27
-
28
- function authLabel(src) {
29
- if (src.profile) return `[profile: ${src.profile}]`;
30
- if (src.token) return '[token: ***]';
31
- return '';
32
- }
33
-
34
- /**
35
- * wyvrnpm configure add-source --kind install|publish --name <name> --url <url>
36
- * [--profile <profile>] [--token <token>]
37
- */
38
- function addSource(argv) {
39
- const { kind, name, url, profile, token } = argv;
40
- const config = readConfig();
41
- const key = kind === 'install' ? 'installSources' : 'publishSources';
42
-
43
- const entry = { name, url };
44
- if (profile) entry.profile = profile;
45
- if (token) entry.token = token;
46
-
47
- const idx = config[key].findIndex((s) => s.name === name);
48
- if (idx !== -1) {
49
- config[key][idx] = entry;
50
- console.log(`[wyvrn] Updated ${kind} source "${name}"`);
51
- } else {
52
- config[key].push(entry);
53
- console.log(`[wyvrn] Added ${kind} source "${name}"`);
54
- }
55
-
56
- writeConfig(config);
57
- console.log(`[wyvrn] Saved to ${getConfigPath()}`);
58
- }
59
-
60
- /**
61
- * wyvrnpm configure remove-source --kind install|publish --name <name>
62
- */
63
- function removeSource(argv) {
64
- const { kind, name } = argv;
65
- const config = readConfig();
66
- const key = kind === 'install' ? 'installSources' : 'publishSources';
67
-
68
- const before = config[key].length;
69
- config[key] = config[key].filter((s) => s.name !== name);
70
-
71
- if (config[key].length === before) {
72
- console.error(`[wyvrn] Error: No ${kind} source named "${name}"`);
73
- process.exit(1);
74
- }
75
-
76
- writeConfig(config);
77
- console.log(`[wyvrn] Removed ${kind} source "${name}"`);
78
- }
79
-
80
- module.exports = { list, addSource, removeSource };
1
+ 'use strict';
2
+
3
+ const { readConfig, writeConfig, getConfigPath } = require('../config');
4
+
5
+ /** wyvrnpm configure list */
6
+ function list() {
7
+ const config = readConfig();
8
+
9
+ console.log(`Config: ${getConfigPath()}\n`);
10
+
11
+ printSection('Install Sources', config.installSources);
12
+ console.log('');
13
+ printSection('Publish Sources', config.publishSources);
14
+ }
15
+
16
+ function printSection(title, sources) {
17
+ console.log(`${title}:`);
18
+ if (sources.length === 0) {
19
+ console.log(' (none)');
20
+ return;
21
+ }
22
+ for (const src of sources) {
23
+ const auth = authLabel(src);
24
+ console.log(` ${src.name.padEnd(20)} ${src.url}${auth ? ' ' + auth : ''}`);
25
+ }
26
+ }
27
+
28
+ function authLabel(src) {
29
+ if (src.profile) return `[profile: ${src.profile}]`;
30
+ if (src.token) return '[token: ***]';
31
+ return '';
32
+ }
33
+
34
+ /**
35
+ * wyvrnpm configure add-source --kind install|publish --name <name> --url <url>
36
+ * [--profile <profile>] [--token <token>]
37
+ */
38
+ function addSource(argv) {
39
+ const { kind, name, url, profile, token } = argv;
40
+ const config = readConfig();
41
+ const key = kind === 'install' ? 'installSources' : 'publishSources';
42
+
43
+ const entry = { name, url };
44
+ if (profile) entry.profile = profile;
45
+ if (token) entry.token = token;
46
+
47
+ const idx = config[key].findIndex((s) => s.name === name);
48
+ if (idx !== -1) {
49
+ config[key][idx] = entry;
50
+ console.log(`[wyvrn] Updated ${kind} source "${name}"`);
51
+ } else {
52
+ config[key].push(entry);
53
+ console.log(`[wyvrn] Added ${kind} source "${name}"`);
54
+ }
55
+
56
+ writeConfig(config);
57
+ console.log(`[wyvrn] Saved to ${getConfigPath()}`);
58
+ }
59
+
60
+ /**
61
+ * wyvrnpm configure remove-source --kind install|publish --name <name>
62
+ */
63
+ function removeSource(argv) {
64
+ const { kind, name } = argv;
65
+ const config = readConfig();
66
+ const key = kind === 'install' ? 'installSources' : 'publishSources';
67
+
68
+ const before = config[key].length;
69
+ config[key] = config[key].filter((s) => s.name !== name);
70
+
71
+ if (config[key].length === before) {
72
+ console.error(`[wyvrn] Error: No ${kind} source named "${name}"`);
73
+ process.exit(1);
74
+ }
75
+
76
+ writeConfig(config);
77
+ console.log(`[wyvrn] Removed ${kind} source "${name}"`);
78
+ }
79
+
80
+ module.exports = { list, addSource, removeSource };
@@ -1,33 +1,33 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const { defaultManifest, writeManifest } = require('../manifest');
6
-
7
- /**
8
- * Initialises a new wyvrn.json manifest in the project root.
9
- * If a manifest already exists the command exits early without overwriting it.
10
- *
11
- * @param {object} argv - Parsed yargs arguments.
12
- * @param {string} argv.manifest - Path to the manifest file.
13
- * @param {string} argv.root - Project root directory.
14
- * @returns {Promise<void>}
15
- */
16
- async function init(argv) {
17
- const manifestPath = path.resolve(argv.manifest);
18
- const rootDir = path.resolve(argv.root);
19
-
20
- if (fs.existsSync(manifestPath)) {
21
- console.log(`[wyvrn] Manifest already exists at ${manifestPath}`);
22
- return;
23
- }
24
-
25
- const projectName = path.basename(rootDir);
26
- const manifest = defaultManifest(projectName);
27
-
28
- writeManifest(manifestPath, manifest);
29
-
30
- console.log(`[wyvrn] Created manifest at ${manifestPath}`);
31
- }
32
-
33
- module.exports = init;
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { defaultManifest, writeManifest } = require('../manifest');
6
+
7
+ /**
8
+ * Initialises a new wyvrn.json manifest in the project root.
9
+ * If a manifest already exists the command exits early without overwriting it.
10
+ *
11
+ * @param {object} argv - Parsed yargs arguments.
12
+ * @param {string} argv.manifest - Path to the manifest file.
13
+ * @param {string} argv.root - Project root directory.
14
+ * @returns {Promise<void>}
15
+ */
16
+ async function init(argv) {
17
+ const manifestPath = path.resolve(argv.manifest);
18
+ const rootDir = path.resolve(argv.root);
19
+
20
+ if (fs.existsSync(manifestPath)) {
21
+ console.log(`[wyvrn] Manifest already exists at ${manifestPath}`);
22
+ return;
23
+ }
24
+
25
+ const projectName = path.basename(rootDir);
26
+ const manifest = defaultManifest(projectName);
27
+
28
+ writeManifest(manifestPath, manifest);
29
+
30
+ console.log(`[wyvrn] Created manifest at ${manifestPath}`);
31
+ }
32
+
33
+ module.exports = init;
@@ -1,109 +1,109 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const { readManifest } = require('../manifest');
6
- const { resolveDependencies } = require('../resolve');
7
- const { downloadDependencies } = require('../download');
8
- const { readConfig } = require('../config');
9
-
10
- /**
11
- * Resolves and downloads all dependencies declared in the manifest, then writes
12
- * a wyvrn.lock file recording exactly what was installed.
13
- *
14
- * @param {object} argv - Parsed yargs arguments.
15
- * @param {string} argv.manifest - Path to wyvrn.json.
16
- * @param {string} argv.root - Project root directory.
17
- * @param {string[]} [argv.source] - One or more base URLs for package sources.
18
- * @param {string} argv.platform - Target platform string.
19
- * @param {number} argv.timeout - HTTP timeout in seconds.
20
- * @returns {Promise<void>}
21
- */
22
- async function install(argv) {
23
- const manifestPath = path.resolve(argv.manifest);
24
- const rootDir = path.resolve(argv.root);
25
-
26
- // CLI --source takes priority; fall back to config installSources.
27
- let packageSources;
28
- if (argv.source && argv.source.length > 0) {
29
- packageSources = argv.source;
30
- } else {
31
- const config = readConfig();
32
- packageSources = config.installSources.map((s) => s.url);
33
- if (packageSources.length > 0) {
34
- console.log(`[wyvrn] Using ${packageSources.length} source(s) from config`);
35
- }
36
- }
37
-
38
- if (packageSources.length === 0) {
39
- console.warn(
40
- '[wyvrn] Warning: no sources configured. ' +
41
- 'Pass --source <url> or run: wyvrnpm configure add-source --kind install ...',
42
- );
43
- }
44
-
45
- const lockPath = path.join(path.dirname(manifestPath), 'wyvrn.lock');
46
- const lockedVersions = new Map();
47
- if (fs.existsSync(lockPath)) {
48
- try {
49
- const lock = JSON.parse(fs.readFileSync(lockPath, 'utf8'));
50
- for (const [name, version] of Object.entries(lock.packages || {})) {
51
- lockedVersions.set(name, version);
52
- }
53
- console.log(`[wyvrn] Lock file found — ${lockedVersions.size} pinned package(s)`);
54
- } catch {
55
- console.warn('[wyvrn] Warning: could not read wyvrn.lock, resolving from scratch');
56
- }
57
- }
58
-
59
- const manifest = readManifest(manifestPath);
60
-
61
- // Normalize dependencies: support both array [{ Name, Version }] and object { name: version }.
62
- const rawDeps = manifest.dependencies || manifest.Dependencies || {};
63
- const rootDeps = Array.isArray(rawDeps)
64
- ? Object.fromEntries(rawDeps.map((d) => [d.Name ?? d.name, d.Version ?? d.version]))
65
- : rawDeps;
66
-
67
- console.log(
68
- `[wyvrn] Installing dependencies for "${manifest.name}" (platform: ${argv.platform})`,
69
- );
70
-
71
- const resolvedDeps = await resolveDependencies(
72
- rootDeps,
73
- packageSources,
74
- argv.platform,
75
- fetch,
76
- lockedVersions,
77
- );
78
-
79
- const razerDir = path.join(rootDir, 'wyvrn_internal');
80
-
81
- await downloadDependencies(
82
- resolvedDeps,
83
- packageSources,
84
- argv.platform,
85
- razerDir,
86
- fetch,
87
- argv.timeout,
88
- );
89
-
90
- // Build lock file — packages sorted alphabetically for deterministic diffs.
91
- const sortedPackages = {};
92
- for (const key of [...resolvedDeps.keys()].sort()) {
93
- sortedPackages[key] = resolvedDeps.get(key);
94
- }
95
-
96
- const lockData = {
97
- generatedAt: new Date().toISOString(),
98
- platform: argv.platform,
99
- packages: sortedPackages,
100
- };
101
-
102
- fs.writeFileSync(lockPath, JSON.stringify(lockData, null, 2) + '\n', 'utf8');
103
- console.log(`[wyvrn] Lock file written to ${lockPath}`);
104
-
105
- const count = resolvedDeps.size;
106
- console.log(`[wyvrn] Done — ${count} package${count !== 1 ? 's' : ''} installed.`);
107
- }
108
-
109
- module.exports = install;
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { readManifest } = require('../manifest');
6
+ const { resolveDependencies } = require('../resolve');
7
+ const { downloadDependencies } = require('../download');
8
+ const { readConfig } = require('../config');
9
+
10
+ /**
11
+ * Resolves and downloads all dependencies declared in the manifest, then writes
12
+ * a wyvrn.lock file recording exactly what was installed.
13
+ *
14
+ * @param {object} argv - Parsed yargs arguments.
15
+ * @param {string} argv.manifest - Path to wyvrn.json.
16
+ * @param {string} argv.root - Project root directory.
17
+ * @param {string[]} [argv.source] - One or more base URLs for package sources.
18
+ * @param {string} argv.platform - Target platform string.
19
+ * @param {number} argv.timeout - HTTP timeout in seconds.
20
+ * @returns {Promise<void>}
21
+ */
22
+ async function install(argv) {
23
+ const manifestPath = path.resolve(argv.manifest);
24
+ const rootDir = path.resolve(argv.root);
25
+
26
+ // CLI --source takes priority; fall back to config installSources.
27
+ let packageSources;
28
+ if (argv.source && argv.source.length > 0) {
29
+ packageSources = argv.source;
30
+ } else {
31
+ const config = readConfig();
32
+ packageSources = config.installSources.map((s) => s.url);
33
+ if (packageSources.length > 0) {
34
+ console.log(`[wyvrn] Using ${packageSources.length} source(s) from config`);
35
+ }
36
+ }
37
+
38
+ if (packageSources.length === 0) {
39
+ console.warn(
40
+ '[wyvrn] Warning: no sources configured. ' +
41
+ 'Pass --source <url> or run: wyvrnpm configure add-source --kind install ...',
42
+ );
43
+ }
44
+
45
+ const lockPath = path.join(path.dirname(manifestPath), 'wyvrn.lock');
46
+ const lockedVersions = new Map();
47
+ if (fs.existsSync(lockPath)) {
48
+ try {
49
+ const lock = JSON.parse(fs.readFileSync(lockPath, 'utf8'));
50
+ for (const [name, version] of Object.entries(lock.packages || {})) {
51
+ lockedVersions.set(name, version);
52
+ }
53
+ console.log(`[wyvrn] Lock file found — ${lockedVersions.size} pinned package(s)`);
54
+ } catch {
55
+ console.warn('[wyvrn] Warning: could not read wyvrn.lock, resolving from scratch');
56
+ }
57
+ }
58
+
59
+ const manifest = readManifest(manifestPath);
60
+
61
+ // Normalize dependencies: support both array [{ Name, Version }] and object { name: version }.
62
+ const rawDeps = manifest.dependencies || manifest.Dependencies || {};
63
+ const rootDeps = Array.isArray(rawDeps)
64
+ ? Object.fromEntries(rawDeps.map((d) => [d.Name ?? d.name, d.Version ?? d.version]))
65
+ : rawDeps;
66
+
67
+ console.log(
68
+ `[wyvrn] Installing dependencies for "${manifest.name}" (platform: ${argv.platform})`,
69
+ );
70
+
71
+ const resolvedDeps = await resolveDependencies(
72
+ rootDeps,
73
+ packageSources,
74
+ argv.platform,
75
+ fetch,
76
+ lockedVersions,
77
+ );
78
+
79
+ const razerDir = path.join(rootDir, 'wyvrn_internal');
80
+
81
+ await downloadDependencies(
82
+ resolvedDeps,
83
+ packageSources,
84
+ argv.platform,
85
+ razerDir,
86
+ fetch,
87
+ argv.timeout,
88
+ );
89
+
90
+ // Build lock file — packages sorted alphabetically for deterministic diffs.
91
+ const sortedPackages = {};
92
+ for (const key of [...resolvedDeps.keys()].sort()) {
93
+ sortedPackages[key] = resolvedDeps.get(key);
94
+ }
95
+
96
+ const lockData = {
97
+ generatedAt: new Date().toISOString(),
98
+ platform: argv.platform,
99
+ packages: sortedPackages,
100
+ };
101
+
102
+ fs.writeFileSync(lockPath, JSON.stringify(lockData, null, 2) + '\n', 'utf8');
103
+ console.log(`[wyvrn] Lock file written to ${lockPath}`);
104
+
105
+ const count = resolvedDeps.size;
106
+ console.log(`[wyvrn] Done — ${count} package${count !== 1 ? 's' : ''} installed.`);
107
+ }
108
+
109
+ module.exports = install;