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.
- package/README.md +1914 -1860
- package/bin/{wyvrn.js → wyvrnpm.js} +66 -0
- package/cmake/cpp.cmake +9 -9
- package/cmake/functions.cmake +224 -224
- package/cmake/macros.cmake +284 -284
- package/package.json +3 -2
- package/src/auth.js +66 -66
- package/src/binary-dir.js +95 -0
- package/src/bootstrap/cookbook.js +196 -196
- package/src/bootstrap/detect.js +150 -150
- package/src/bootstrap/index.js +220 -220
- package/src/bootstrap/version.js +72 -72
- package/src/build/cache.js +344 -344
- package/src/build/clone.js +170 -170
- package/src/build/cmake.js +342 -342
- package/src/build/index.js +299 -297
- package/src/build/msvc-env.js +260 -260
- package/src/build/recipe.js +188 -188
- package/src/commands/add.js +141 -141
- package/src/commands/bootstrap.js +96 -96
- package/src/commands/build.js +482 -452
- package/src/commands/cache.js +189 -189
- package/src/commands/clean.js +80 -80
- package/src/commands/configure.js +92 -92
- package/src/commands/init.js +70 -70
- package/src/commands/install-skill.js +115 -115
- package/src/commands/install.js +730 -674
- package/src/commands/link.js +320 -320
- package/src/commands/profile.js +237 -237
- package/src/commands/publish.js +584 -555
- package/src/commands/show.js +252 -252
- package/src/commands/version.js +187 -0
- package/src/compat.js +273 -273
- package/src/conf/index.js +415 -391
- package/src/conf/namespaces.js +94 -94
- package/src/context.js +230 -230
- package/src/http-fetch.js +53 -53
- package/src/ignore.js +118 -118
- package/src/logger.js +122 -122
- package/src/options.js +303 -303
- package/src/settings-overrides.js +152 -152
- package/src/toolchain/deps.js +164 -164
- package/src/toolchain/index.js +212 -212
- package/src/toolchain/presets.js +356 -340
- package/src/toolchain/template.cmake +77 -77
- package/src/upload-built.js +265 -265
- package/src/version-range.js +301 -301
- package/src/zip-safe.js +52 -52
- package/src/zip-stream.js +126 -0
package/src/commands/profile.js
CHANGED
|
@@ -1,237 +1,237 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
detectProfile,
|
|
5
|
-
hashProfile,
|
|
6
|
-
formatProfile,
|
|
7
|
-
readProfile,
|
|
8
|
-
writeProfile,
|
|
9
|
-
deleteProfile,
|
|
10
|
-
listProfiles,
|
|
11
|
-
getProfilesDir,
|
|
12
|
-
mergeProfile,
|
|
13
|
-
resolveProfileChain,
|
|
14
|
-
} = require('../profile');
|
|
15
|
-
const { readConfig, writeConfig } = require('../config');
|
|
16
|
-
const { parseCliConf, flattenConf, unflattenConf } = require('../conf');
|
|
17
|
-
const log = require('../logger');
|
|
18
|
-
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
// list
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* wyvrnpm configure profile list
|
|
25
|
-
* Show all saved profiles and which one is the default.
|
|
26
|
-
*/
|
|
27
|
-
function list() {
|
|
28
|
-
const config = readConfig();
|
|
29
|
-
const names = listProfiles();
|
|
30
|
-
const dir = getProfilesDir();
|
|
31
|
-
const defName = config.defaultProfile ?? 'default';
|
|
32
|
-
|
|
33
|
-
log.info(`Profiles directory: ${dir}`);
|
|
34
|
-
log.info(`Default profile : ${defName}`);
|
|
35
|
-
console.log('');
|
|
36
|
-
|
|
37
|
-
if (names.length === 0) {
|
|
38
|
-
console.log(' (no profiles saved — run `wyvrnpm configure profile detect` to create one)');
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
for (const name of names) {
|
|
43
|
-
const marker = name === defName ? ' *' : '';
|
|
44
|
-
let p;
|
|
45
|
-
try { p = resolveProfileChain(name); }
|
|
46
|
-
catch { p = null; } // cycle / missing parent — fall through to (unresolved)
|
|
47
|
-
const summary = p
|
|
48
|
-
? `${p.os}/${p.arch} ${p.compiler} ${p['compiler.version']} C++${p['compiler.cppstd']}` +
|
|
49
|
-
(p['compiler.runtime'] ? ` [${p['compiler.runtime']}]` : '')
|
|
50
|
-
: '(unresolved — check `extends`)';
|
|
51
|
-
console.log(` ${(name + marker).padEnd(24)} ${summary}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
56
|
-
// show
|
|
57
|
-
// ---------------------------------------------------------------------------
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* wyvrnpm configure profile show [--name <name>]
|
|
61
|
-
* Display a specific profile (defaults to the configured default).
|
|
62
|
-
*/
|
|
63
|
-
function show(argv) {
|
|
64
|
-
const config = readConfig();
|
|
65
|
-
const name = argv.name ?? config.defaultProfile ?? 'default';
|
|
66
|
-
|
|
67
|
-
// Raw → displays `extends:` chain for visibility. Resolved → what
|
|
68
|
-
// loadProfile() actually hands to install / publish / build.
|
|
69
|
-
const raw = readProfile(name);
|
|
70
|
-
let resolved;
|
|
71
|
-
try {
|
|
72
|
-
resolved = raw ? resolveProfileChain(name) : null;
|
|
73
|
-
} catch (err) {
|
|
74
|
-
log.error(`Cannot resolve profile "${name}": ${err.message}`);
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (resolved) {
|
|
79
|
-
log.info(`Profile "${name}":`);
|
|
80
|
-
if (raw.extends !== undefined && raw.extends !== null) {
|
|
81
|
-
const chain = Array.isArray(raw.extends) ? raw.extends.join(', ') : raw.extends;
|
|
82
|
-
log.info(` extends: ${chain}`);
|
|
83
|
-
}
|
|
84
|
-
console.log(formatProfile(resolved));
|
|
85
|
-
console.log(`\nProfile hash : ${hashProfile(resolved)}`);
|
|
86
|
-
} else {
|
|
87
|
-
const detected = detectProfile();
|
|
88
|
-
log.info(`Profile "${name}" not found — showing auto-detected environment:`);
|
|
89
|
-
console.log(formatProfile(detected));
|
|
90
|
-
console.log(`\nProfile hash : ${hashProfile(detected)}`);
|
|
91
|
-
console.log(`\nRun \`wyvrnpm configure profile detect --name ${name}\` to save this.`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// ---------------------------------------------------------------------------
|
|
96
|
-
// detect
|
|
97
|
-
// ---------------------------------------------------------------------------
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* wyvrnpm configure profile detect [--name <name>] [--dry-run]
|
|
101
|
-
* Auto-detect the current build environment and save it as a named profile.
|
|
102
|
-
*/
|
|
103
|
-
function detect(argv) {
|
|
104
|
-
const config = readConfig();
|
|
105
|
-
const name = argv.name ?? config.defaultProfile ?? 'default';
|
|
106
|
-
const p = detectProfile();
|
|
107
|
-
|
|
108
|
-
log.info('Detected profile:');
|
|
109
|
-
console.log(formatProfile(p));
|
|
110
|
-
console.log(`\nProfile hash : ${hashProfile(p)}`);
|
|
111
|
-
|
|
112
|
-
if (!argv.dryRun) {
|
|
113
|
-
writeProfile(name, p);
|
|
114
|
-
console.log('');
|
|
115
|
-
log.success(`Saved as profile "${name}".`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ---------------------------------------------------------------------------
|
|
120
|
-
// set
|
|
121
|
-
// ---------------------------------------------------------------------------
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* wyvrnpm configure profile set [--name <name>] [field options] [--conf KEY=VAL]
|
|
125
|
-
* Manually override individual fields in a named profile.
|
|
126
|
-
* Starts from the existing saved profile, or auto-detects if none exists yet.
|
|
127
|
-
*
|
|
128
|
-
* --conf <namespace.leaf>=<value> (repeatable) — set a non-ABI build-time
|
|
129
|
-
* knob in the profile's `[conf]` block (PLAN-CONF.md phase 2). Same
|
|
130
|
-
* syntax as `install --conf` / `build --conf`; `KEY` alone means
|
|
131
|
-
* `KEY=ON`, `KEY=` removes any inherited value from this profile.
|
|
132
|
-
* Profile conf never folds into `profileHash`. Allow-listed
|
|
133
|
-
* namespaces only — unknown keys fail fast.
|
|
134
|
-
*/
|
|
135
|
-
function set(argv) {
|
|
136
|
-
const config = readConfig();
|
|
137
|
-
const name = argv.name ?? config.defaultProfile ?? 'default';
|
|
138
|
-
const base = readProfile(name) ?? detectProfile();
|
|
139
|
-
|
|
140
|
-
const updated = mergeProfile(base, {
|
|
141
|
-
os: argv.os ?? null,
|
|
142
|
-
arch: argv.arch ?? null,
|
|
143
|
-
compiler: argv.compiler ?? null,
|
|
144
|
-
'compiler.version': argv.compilerVersion ?? null,
|
|
145
|
-
'compiler.cppstd': argv.cppstd ?? null,
|
|
146
|
-
'compiler.runtime': argv.runtime ?? null,
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// Apply --conf edits, if any. Writes at the leaf level, preserving
|
|
150
|
-
// sibling keys that weren't mentioned. `KEY=` removes the leaf.
|
|
151
|
-
const cliConf = Array.isArray(argv.conf) ? argv.conf : (argv.conf ? [argv.conf] : []);
|
|
152
|
-
if (cliConf.length > 0) {
|
|
153
|
-
let { sets, unsets } = { sets: {}, unsets: new Set() };
|
|
154
|
-
try { ({ sets, unsets } = parseCliConf(cliConf)); }
|
|
155
|
-
catch (err) {
|
|
156
|
-
log.error(`--conf: ${err.message}`);
|
|
157
|
-
process.exit(1);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const existingFlat = (() => {
|
|
161
|
-
try { return updated.conf ? flattenConf(updated.conf) : {}; }
|
|
162
|
-
catch (err) {
|
|
163
|
-
log.error(`existing profile conf is malformed: ${err.message}`);
|
|
164
|
-
process.exit(1);
|
|
165
|
-
}
|
|
166
|
-
})();
|
|
167
|
-
|
|
168
|
-
const nextFlat = { ...existingFlat, ...sets };
|
|
169
|
-
for (const k of unsets) delete nextFlat[k];
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
// Re-validate as a whole so namespace/leaf checks catch both the
|
|
173
|
-
// edits AND any previously-saved pre-phase-2 garbage.
|
|
174
|
-
require('../conf/namespaces').validateFlatConfKeys(nextFlat);
|
|
175
|
-
} catch (err) {
|
|
176
|
-
log.error(`--conf: ${err.message}`);
|
|
177
|
-
process.exit(1);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (Object.keys(nextFlat).length === 0) {
|
|
181
|
-
delete updated.conf;
|
|
182
|
-
} else {
|
|
183
|
-
updated.conf = unflattenConf(nextFlat);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
writeProfile(name, updated);
|
|
188
|
-
|
|
189
|
-
log.info(`Profile "${name}" updated:`);
|
|
190
|
-
console.log(formatProfile(updated));
|
|
191
|
-
console.log(`\nProfile hash : ${hashProfile(updated)}`);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// ---------------------------------------------------------------------------
|
|
195
|
-
// setDefault
|
|
196
|
-
// ---------------------------------------------------------------------------
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* wyvrnpm configure profile set-default <name>
|
|
200
|
-
* Change which named profile is used by default.
|
|
201
|
-
*/
|
|
202
|
-
function setDefault(argv) {
|
|
203
|
-
const name = argv.name;
|
|
204
|
-
if (!readProfile(name)) {
|
|
205
|
-
log.error(`profile "${name}" does not exist. Create it first.`);
|
|
206
|
-
process.exit(1);
|
|
207
|
-
}
|
|
208
|
-
const config = readConfig();
|
|
209
|
-
config.defaultProfile = name;
|
|
210
|
-
writeConfig(config);
|
|
211
|
-
log.info(`Default profile set to "${name}".`);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// ---------------------------------------------------------------------------
|
|
215
|
-
// del
|
|
216
|
-
// ---------------------------------------------------------------------------
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* wyvrnpm configure profile delete <name>
|
|
220
|
-
* Remove a saved profile file.
|
|
221
|
-
*/
|
|
222
|
-
function del(argv) {
|
|
223
|
-
const name = argv.name;
|
|
224
|
-
if (name === 'default') {
|
|
225
|
-
log.error('cannot delete the "default" profile.');
|
|
226
|
-
process.exit(1);
|
|
227
|
-
}
|
|
228
|
-
const removed = deleteProfile(name);
|
|
229
|
-
if (removed) {
|
|
230
|
-
log.info(`Profile "${name}" deleted.`);
|
|
231
|
-
} else {
|
|
232
|
-
log.error(`profile "${name}" not found.`);
|
|
233
|
-
process.exit(1);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
module.exports = { list, show, detect, set, setDefault, del };
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
detectProfile,
|
|
5
|
+
hashProfile,
|
|
6
|
+
formatProfile,
|
|
7
|
+
readProfile,
|
|
8
|
+
writeProfile,
|
|
9
|
+
deleteProfile,
|
|
10
|
+
listProfiles,
|
|
11
|
+
getProfilesDir,
|
|
12
|
+
mergeProfile,
|
|
13
|
+
resolveProfileChain,
|
|
14
|
+
} = require('../profile');
|
|
15
|
+
const { readConfig, writeConfig } = require('../config');
|
|
16
|
+
const { parseCliConf, flattenConf, unflattenConf } = require('../conf');
|
|
17
|
+
const log = require('../logger');
|
|
18
|
+
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// list
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* wyvrnpm configure profile list
|
|
25
|
+
* Show all saved profiles and which one is the default.
|
|
26
|
+
*/
|
|
27
|
+
function list() {
|
|
28
|
+
const config = readConfig();
|
|
29
|
+
const names = listProfiles();
|
|
30
|
+
const dir = getProfilesDir();
|
|
31
|
+
const defName = config.defaultProfile ?? 'default';
|
|
32
|
+
|
|
33
|
+
log.info(`Profiles directory: ${dir}`);
|
|
34
|
+
log.info(`Default profile : ${defName}`);
|
|
35
|
+
console.log('');
|
|
36
|
+
|
|
37
|
+
if (names.length === 0) {
|
|
38
|
+
console.log(' (no profiles saved — run `wyvrnpm configure profile detect` to create one)');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (const name of names) {
|
|
43
|
+
const marker = name === defName ? ' *' : '';
|
|
44
|
+
let p;
|
|
45
|
+
try { p = resolveProfileChain(name); }
|
|
46
|
+
catch { p = null; } // cycle / missing parent — fall through to (unresolved)
|
|
47
|
+
const summary = p
|
|
48
|
+
? `${p.os}/${p.arch} ${p.compiler} ${p['compiler.version']} C++${p['compiler.cppstd']}` +
|
|
49
|
+
(p['compiler.runtime'] ? ` [${p['compiler.runtime']}]` : '')
|
|
50
|
+
: '(unresolved — check `extends`)';
|
|
51
|
+
console.log(` ${(name + marker).padEnd(24)} ${summary}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// show
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* wyvrnpm configure profile show [--name <name>]
|
|
61
|
+
* Display a specific profile (defaults to the configured default).
|
|
62
|
+
*/
|
|
63
|
+
function show(argv) {
|
|
64
|
+
const config = readConfig();
|
|
65
|
+
const name = argv.name ?? config.defaultProfile ?? 'default';
|
|
66
|
+
|
|
67
|
+
// Raw → displays `extends:` chain for visibility. Resolved → what
|
|
68
|
+
// loadProfile() actually hands to install / publish / build.
|
|
69
|
+
const raw = readProfile(name);
|
|
70
|
+
let resolved;
|
|
71
|
+
try {
|
|
72
|
+
resolved = raw ? resolveProfileChain(name) : null;
|
|
73
|
+
} catch (err) {
|
|
74
|
+
log.error(`Cannot resolve profile "${name}": ${err.message}`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (resolved) {
|
|
79
|
+
log.info(`Profile "${name}":`);
|
|
80
|
+
if (raw.extends !== undefined && raw.extends !== null) {
|
|
81
|
+
const chain = Array.isArray(raw.extends) ? raw.extends.join(', ') : raw.extends;
|
|
82
|
+
log.info(` extends: ${chain}`);
|
|
83
|
+
}
|
|
84
|
+
console.log(formatProfile(resolved));
|
|
85
|
+
console.log(`\nProfile hash : ${hashProfile(resolved)}`);
|
|
86
|
+
} else {
|
|
87
|
+
const detected = detectProfile();
|
|
88
|
+
log.info(`Profile "${name}" not found — showing auto-detected environment:`);
|
|
89
|
+
console.log(formatProfile(detected));
|
|
90
|
+
console.log(`\nProfile hash : ${hashProfile(detected)}`);
|
|
91
|
+
console.log(`\nRun \`wyvrnpm configure profile detect --name ${name}\` to save this.`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// detect
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* wyvrnpm configure profile detect [--name <name>] [--dry-run]
|
|
101
|
+
* Auto-detect the current build environment and save it as a named profile.
|
|
102
|
+
*/
|
|
103
|
+
function detect(argv) {
|
|
104
|
+
const config = readConfig();
|
|
105
|
+
const name = argv.name ?? config.defaultProfile ?? 'default';
|
|
106
|
+
const p = detectProfile();
|
|
107
|
+
|
|
108
|
+
log.info('Detected profile:');
|
|
109
|
+
console.log(formatProfile(p));
|
|
110
|
+
console.log(`\nProfile hash : ${hashProfile(p)}`);
|
|
111
|
+
|
|
112
|
+
if (!argv.dryRun) {
|
|
113
|
+
writeProfile(name, p);
|
|
114
|
+
console.log('');
|
|
115
|
+
log.success(`Saved as profile "${name}".`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
// set
|
|
121
|
+
// ---------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* wyvrnpm configure profile set [--name <name>] [field options] [--conf KEY=VAL]
|
|
125
|
+
* Manually override individual fields in a named profile.
|
|
126
|
+
* Starts from the existing saved profile, or auto-detects if none exists yet.
|
|
127
|
+
*
|
|
128
|
+
* --conf <namespace.leaf>=<value> (repeatable) — set a non-ABI build-time
|
|
129
|
+
* knob in the profile's `[conf]` block (PLAN-CONF.md phase 2). Same
|
|
130
|
+
* syntax as `install --conf` / `build --conf`; `KEY` alone means
|
|
131
|
+
* `KEY=ON`, `KEY=` removes any inherited value from this profile.
|
|
132
|
+
* Profile conf never folds into `profileHash`. Allow-listed
|
|
133
|
+
* namespaces only — unknown keys fail fast.
|
|
134
|
+
*/
|
|
135
|
+
function set(argv) {
|
|
136
|
+
const config = readConfig();
|
|
137
|
+
const name = argv.name ?? config.defaultProfile ?? 'default';
|
|
138
|
+
const base = readProfile(name) ?? detectProfile();
|
|
139
|
+
|
|
140
|
+
const updated = mergeProfile(base, {
|
|
141
|
+
os: argv.os ?? null,
|
|
142
|
+
arch: argv.arch ?? null,
|
|
143
|
+
compiler: argv.compiler ?? null,
|
|
144
|
+
'compiler.version': argv.compilerVersion ?? null,
|
|
145
|
+
'compiler.cppstd': argv.cppstd ?? null,
|
|
146
|
+
'compiler.runtime': argv.runtime ?? null,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Apply --conf edits, if any. Writes at the leaf level, preserving
|
|
150
|
+
// sibling keys that weren't mentioned. `KEY=` removes the leaf.
|
|
151
|
+
const cliConf = Array.isArray(argv.conf) ? argv.conf : (argv.conf ? [argv.conf] : []);
|
|
152
|
+
if (cliConf.length > 0) {
|
|
153
|
+
let { sets, unsets } = { sets: {}, unsets: new Set() };
|
|
154
|
+
try { ({ sets, unsets } = parseCliConf(cliConf)); }
|
|
155
|
+
catch (err) {
|
|
156
|
+
log.error(`--conf: ${err.message}`);
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const existingFlat = (() => {
|
|
161
|
+
try { return updated.conf ? flattenConf(updated.conf) : {}; }
|
|
162
|
+
catch (err) {
|
|
163
|
+
log.error(`existing profile conf is malformed: ${err.message}`);
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
})();
|
|
167
|
+
|
|
168
|
+
const nextFlat = { ...existingFlat, ...sets };
|
|
169
|
+
for (const k of unsets) delete nextFlat[k];
|
|
170
|
+
|
|
171
|
+
try {
|
|
172
|
+
// Re-validate as a whole so namespace/leaf checks catch both the
|
|
173
|
+
// edits AND any previously-saved pre-phase-2 garbage.
|
|
174
|
+
require('../conf/namespaces').validateFlatConfKeys(nextFlat);
|
|
175
|
+
} catch (err) {
|
|
176
|
+
log.error(`--conf: ${err.message}`);
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (Object.keys(nextFlat).length === 0) {
|
|
181
|
+
delete updated.conf;
|
|
182
|
+
} else {
|
|
183
|
+
updated.conf = unflattenConf(nextFlat);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
writeProfile(name, updated);
|
|
188
|
+
|
|
189
|
+
log.info(`Profile "${name}" updated:`);
|
|
190
|
+
console.log(formatProfile(updated));
|
|
191
|
+
console.log(`\nProfile hash : ${hashProfile(updated)}`);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// ---------------------------------------------------------------------------
|
|
195
|
+
// setDefault
|
|
196
|
+
// ---------------------------------------------------------------------------
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* wyvrnpm configure profile set-default <name>
|
|
200
|
+
* Change which named profile is used by default.
|
|
201
|
+
*/
|
|
202
|
+
function setDefault(argv) {
|
|
203
|
+
const name = argv.name;
|
|
204
|
+
if (!readProfile(name)) {
|
|
205
|
+
log.error(`profile "${name}" does not exist. Create it first.`);
|
|
206
|
+
process.exit(1);
|
|
207
|
+
}
|
|
208
|
+
const config = readConfig();
|
|
209
|
+
config.defaultProfile = name;
|
|
210
|
+
writeConfig(config);
|
|
211
|
+
log.info(`Default profile set to "${name}".`);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// ---------------------------------------------------------------------------
|
|
215
|
+
// del
|
|
216
|
+
// ---------------------------------------------------------------------------
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* wyvrnpm configure profile delete <name>
|
|
220
|
+
* Remove a saved profile file.
|
|
221
|
+
*/
|
|
222
|
+
function del(argv) {
|
|
223
|
+
const name = argv.name;
|
|
224
|
+
if (name === 'default') {
|
|
225
|
+
log.error('cannot delete the "default" profile.');
|
|
226
|
+
process.exit(1);
|
|
227
|
+
}
|
|
228
|
+
const removed = deleteProfile(name);
|
|
229
|
+
if (removed) {
|
|
230
|
+
log.info(`Profile "${name}" deleted.`);
|
|
231
|
+
} else {
|
|
232
|
+
log.error(`profile "${name}" not found.`);
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
module.exports = { list, show, detect, set, setDefault, del };
|