-
Notifications
You must be signed in to change notification settings - Fork 1
/
fixpack:configure.js
103 lines (97 loc) · 1.91 KB
/
fixpack:configure.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import update from '../lib/update.js';
import contains from '../lib/contains.js';
import stringify from '../lib/json/stringify.js';
const filename = '.fixpackrc';
export const description = `Update or create ${filename}.`;
export const commit = {
type: 'config',
scope: 'fixpack',
subject: description,
};
export async function postcondition({readJSON, assert}) {
await contains({
assert,
read: () => readJSON(filename),
test: (contents) => assert.deepStrictEqual(contents, expected),
});
}
export async function precondition({readJSON, assert}) {
await contains({
assert,
read: () => readJSON(filename),
mustExist: false,
test: (contents) => assert.notDeepStrictEqual(contents, expected),
});
}
export async function apply({read, write}) {
await update({
create: true,
read: () => read(filename),
write: (data) => write(filename, data),
edit: () => stringify(expected) + '\n',
});
}
const expected = {
files: ['package.json'],
quiet: false,
required: ['name', 'version'],
requiredOnPrivate: [],
sortToTop: [
'name',
'description',
'version',
'license',
'author',
'homepage',
'repository',
'bugs',
'keywords',
'sideEffects',
'type',
'source',
'main',
'module',
'esmodule',
'umd:main',
'unpkg',
'exports',
'files',
'publishConfig',
'scripts',
'bundledDependencies',
'dependencies',
'optionalDependencies',
'peerDependencies',
'peerDependenciesMeta',
'devDependencies',
],
sortedSubItems: [
'keywords',
'exports',
'files',
'scripts',
'bundledDependencies',
'dependencies',
'optionalDependencies',
'peerDependencies',
'peerDependenciesMeta',
'devDependencies',
],
warn: [
'description',
'author',
'repository',
'keywords',
'main',
'bugs',
'homepage',
'license',
'files',
],
warnOnPrivate: ['name', 'version', 'description', 'main'],
dryRun: false,
wipe: false,
indent: null,
newLine: null,
finalNewLine: null,
};