@w5s/configurator-core 1.0.0-alpha.7 → 1.0.0-alpha.9
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/index.cjs +199 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +114 -91
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +114 -91
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +175 -147
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/FileMode.ts +14 -14
- package/src/__exists.ts +1 -1
- package/src/__toMode.ts +8 -8
- package/src/block.ts +51 -51
- package/src/directory.ts +14 -12
- package/src/exec.ts +23 -23
- package/src/file.ts +17 -15
- package/src/ignoreFile.ts +18 -18
- package/src/index.ts +2 -1
- package/src/json.ts +18 -18
- package/src/meta.ts +2 -2
- package/src/testing/getTempPath.ts +1 -0
- package/src/testing/getTestPath.ts +2 -1
- package/src/yaml.ts +45 -0
- package/src/yarnConfig.ts +13 -13
- package/src/yarnVersion.ts +10 -10
package/src/yarnConfig.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface YarnConfigOptions {
|
|
|
9
9
|
/**
|
|
10
10
|
* Option target state
|
|
11
11
|
*/
|
|
12
|
-
readonly state: '
|
|
12
|
+
readonly state: 'absent' | 'present';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* File content mapping function
|
|
@@ -19,43 +19,43 @@ export interface YarnConfigOptions {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Set/Unset yarn configuration value
|
|
23
23
|
*
|
|
24
24
|
* @param options
|
|
25
25
|
* @example
|
|
26
|
-
*
|
|
26
|
+
* await yarnConfig({
|
|
27
27
|
* key: 'nodeLinker',
|
|
28
28
|
* state: 'present',
|
|
29
29
|
* update: (content) => content.replace('node-modules', 'hoisted'),
|
|
30
30
|
* })
|
|
31
31
|
*/
|
|
32
|
-
export function
|
|
32
|
+
export async function yarnConfig(options: YarnConfigOptions): Promise<void> {
|
|
33
33
|
const { key, state, update } = options;
|
|
34
34
|
if (state === 'present') {
|
|
35
|
-
const { stdout } =
|
|
36
|
-
|
|
35
|
+
const { stdout } = await exec('yarn', ['config', 'get', String(key)]);
|
|
36
|
+
await exec('yarn', ['config', 'set', String(key), String(update == null ? '' : update(stdout))]);
|
|
37
37
|
} else {
|
|
38
|
-
|
|
38
|
+
await exec('yarn', ['config', 'unset']);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Synchronous version of {@link yarnConfig}
|
|
44
44
|
*
|
|
45
45
|
* @param options
|
|
46
46
|
* @example
|
|
47
|
-
*
|
|
47
|
+
* yarnConfigSync({
|
|
48
48
|
* key: 'nodeLinker',
|
|
49
49
|
* state: 'present',
|
|
50
50
|
* update: (content) => content.replace('node-modules', 'hoisted'),
|
|
51
51
|
* })
|
|
52
52
|
*/
|
|
53
|
-
export
|
|
53
|
+
export function yarnConfigSync(options: YarnConfigOptions) {
|
|
54
54
|
const { key, state, update } = options;
|
|
55
55
|
if (state === 'present') {
|
|
56
|
-
const { stdout } =
|
|
57
|
-
|
|
56
|
+
const { stdout } = execSync('yarn', ['config', 'get', String(key)]);
|
|
57
|
+
execSync('yarn', ['config', 'set', String(key), String(update == null ? '' : update(stdout))]);
|
|
58
58
|
} else {
|
|
59
|
-
|
|
59
|
+
execSync('yarn', ['config', 'unset']);
|
|
60
60
|
}
|
|
61
61
|
}
|
package/src/yarnVersion.ts
CHANGED
|
@@ -6,29 +6,29 @@ export interface YarnVersionOptions {
|
|
|
6
6
|
/**
|
|
7
7
|
* Option target state
|
|
8
8
|
*/
|
|
9
|
-
readonly state: '
|
|
9
|
+
readonly state: 'absent' | 'present';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Version mapping function
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
|
-
readonly update?: (() =>
|
|
15
|
+
readonly update?: (() => undefined | YarnVersionKind) | undefined;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Set/Unset yarn configuration value
|
|
20
20
|
*
|
|
21
21
|
* @param options
|
|
22
22
|
* @example
|
|
23
|
-
*
|
|
23
|
+
* await yarnVersion({
|
|
24
24
|
* state: 'present',
|
|
25
25
|
* update: () => 'berry', // or 'classic'
|
|
26
26
|
* })
|
|
27
27
|
*/
|
|
28
|
-
export function
|
|
28
|
+
export async function yarnVersion(options: YarnVersionOptions): Promise<void> {
|
|
29
29
|
const { state, update } = options;
|
|
30
30
|
if (state === 'present') {
|
|
31
|
-
|
|
31
|
+
await exec('yarn', ['set', 'version', String(update == null ? 'berry' : update())]);
|
|
32
32
|
} else {
|
|
33
33
|
// TODO: remove yarn.lock
|
|
34
34
|
throw new Error('Not implemented');
|
|
@@ -36,19 +36,19 @@ export function yarnVersionSync(options: YarnVersionOptions) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Synchronous version of {@link yarnVersion}
|
|
40
40
|
*
|
|
41
41
|
* @param options
|
|
42
42
|
* @example
|
|
43
|
-
*
|
|
43
|
+
* yarnVersionSync({
|
|
44
44
|
* state: 'present',
|
|
45
45
|
* update: () => 'berry', // or 'classic'
|
|
46
46
|
* })
|
|
47
47
|
*/
|
|
48
|
-
export
|
|
48
|
+
export function yarnVersionSync(options: YarnVersionOptions) {
|
|
49
49
|
const { state, update } = options;
|
|
50
50
|
if (state === 'present') {
|
|
51
|
-
|
|
51
|
+
execSync('yarn', ['set', 'version', String(update == null ? 'berry' : update())]);
|
|
52
52
|
} else {
|
|
53
53
|
// TODO: remove yarn.lock
|
|
54
54
|
throw new Error('Not implemented');
|