@dhis2/cli-utils 5.2.0-alpha.9 → 5.2.1-alpha.1
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/package.json +1 -1
- package/src/cmds/release.js +22 -19
- package/src/cmds/schema/diff/index.js +5 -5
- package/src/cmds/schema/fetch.js +1 -1
- package/src/cmds/schema/index.js +2 -2
- package/src/cmds/schema.js +1 -1
- package/src/cmds/uid.js +2 -2
- package/src/index.js +1 -1
- package/src/support/getWorkspacePackages.js +2 -2
- package/src/support/normalizeAndValidatePackages.js +2 -2
- package/src/support/semantic-release-update-deps.js +6 -6
package/package.json
CHANGED
package/src/cmds/release.js
CHANGED
|
@@ -4,7 +4,7 @@ const { reporter } = require('@dhis2/cli-helpers-engine')
|
|
|
4
4
|
const semanticRelease = require('semantic-release').default
|
|
5
5
|
const getWorkspacePackages = require('../support/getWorkspacePackages')
|
|
6
6
|
|
|
7
|
-
const packageIsPublishable = pkgJsonPath => {
|
|
7
|
+
const packageIsPublishable = (pkgJsonPath) => {
|
|
8
8
|
try {
|
|
9
9
|
const pkgJson = require(pkgJsonPath)
|
|
10
10
|
return !!pkgJson.name && !pkgJson.private
|
|
@@ -16,7 +16,7 @@ const packageIsPublishable = pkgJsonPath => {
|
|
|
16
16
|
function publisher(target = '', packages) {
|
|
17
17
|
switch (target.toLowerCase()) {
|
|
18
18
|
case 'npm': {
|
|
19
|
-
return packages.filter(packageIsPublishable).map(pkgJsonPath => {
|
|
19
|
+
return packages.filter(packageIsPublishable).map((pkgJsonPath) => {
|
|
20
20
|
return [
|
|
21
21
|
'@semantic-release/npm',
|
|
22
22
|
{
|
|
@@ -27,7 +27,7 @@ function publisher(target = '', packages) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
default: {
|
|
30
|
-
return packages.map(pkgJsonPath => {
|
|
30
|
+
return packages.map((pkgJsonPath) => {
|
|
31
31
|
return [
|
|
32
32
|
'@semantic-release/npm',
|
|
33
33
|
{
|
|
@@ -41,8 +41,10 @@ function publisher(target = '', packages) {
|
|
|
41
41
|
|
|
42
42
|
const handler = async ({ publish }) => {
|
|
43
43
|
// set up the plugins and filter out any undefined elements
|
|
44
|
-
|
|
45
44
|
const rootPackageFile = path.join(process.cwd(), 'package.json')
|
|
45
|
+
const isPnpm = existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'))
|
|
46
|
+
const lockFile = isPnpm ? 'pnpm-lock.yaml' : 'yarn.lock'
|
|
47
|
+
|
|
46
48
|
const packages = [
|
|
47
49
|
rootPackageFile,
|
|
48
50
|
...(await getWorkspacePackages(rootPackageFile)),
|
|
@@ -71,15 +73,15 @@ const handler = async ({ publish }) => {
|
|
|
71
73
|
{
|
|
72
74
|
assets: [
|
|
73
75
|
'CHANGELOG.md',
|
|
74
|
-
packages.map(pkgJsonPath =>
|
|
76
|
+
packages.map((pkgJsonPath) =>
|
|
75
77
|
path.relative(process.cwd(), pkgJsonPath)
|
|
76
78
|
),
|
|
77
79
|
packages
|
|
78
|
-
.map(pkgJsonPath =>
|
|
79
|
-
path.join(path.dirname(pkgJsonPath),
|
|
80
|
+
.map((pkgJsonPath) =>
|
|
81
|
+
path.join(path.dirname(pkgJsonPath), lockFile)
|
|
80
82
|
)
|
|
81
83
|
.filter(existsSync)
|
|
82
|
-
.map(pkgJsonPath =>
|
|
84
|
+
.map((pkgJsonPath) =>
|
|
83
85
|
path.relative(process.cwd(), pkgJsonPath)
|
|
84
86
|
),
|
|
85
87
|
],
|
|
@@ -88,12 +90,16 @@ const handler = async ({ publish }) => {
|
|
|
88
90
|
},
|
|
89
91
|
]
|
|
90
92
|
|
|
91
|
-
const updateLockFile =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
const updateLockFile = isPnpm
|
|
94
|
+
? [
|
|
95
|
+
'@semantic-release/exec',
|
|
96
|
+
{
|
|
97
|
+
publishCmd:
|
|
98
|
+
'pnpm install --lockfile-only && git commit -am "chore: bump pnpm-lock.yml ${nextRelease.version} [skip ci]" && git push',
|
|
99
|
+
},
|
|
100
|
+
]
|
|
101
|
+
: undefined
|
|
102
|
+
|
|
97
103
|
const deferPlugin = require('../support/semantic-release-defer-release')
|
|
98
104
|
|
|
99
105
|
// Order matters here!
|
|
@@ -110,7 +116,7 @@ const handler = async ({ publish }) => {
|
|
|
110
116
|
[
|
|
111
117
|
'@semantic-release/git',
|
|
112
118
|
{
|
|
113
|
-
assets: [
|
|
119
|
+
assets: [lockFile],
|
|
114
120
|
message:
|
|
115
121
|
'chore: bump pnpm-lock.yml ${nextRelease.version} [skip ci]',
|
|
116
122
|
},
|
|
@@ -123,7 +129,7 @@ const handler = async ({ publish }) => {
|
|
|
123
129
|
* https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md
|
|
124
130
|
*/
|
|
125
131
|
const options = {
|
|
126
|
-
plugins: plugins.filter(n => !!n),
|
|
132
|
+
plugins: plugins.filter((n) => !!n),
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
const config = {
|
|
@@ -134,7 +140,6 @@ const handler = async ({ publish }) => {
|
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
try {
|
|
137
|
-
console.log(semanticRelease)
|
|
138
143
|
const result = await semanticRelease(options, config)
|
|
139
144
|
|
|
140
145
|
if (result) {
|
|
@@ -176,5 +181,3 @@ module.exports = {
|
|
|
176
181
|
},
|
|
177
182
|
},
|
|
178
183
|
}
|
|
179
|
-
|
|
180
|
-
// handler({ publish: 'npm' })
|
|
@@ -16,11 +16,11 @@ const DHIS2HtmlFormatter = require('./schemaHtmlFormatter')
|
|
|
16
16
|
let cache
|
|
17
17
|
// We use the singular property as an unique identifier for schemas
|
|
18
18
|
// name and type are used for other nested properties
|
|
19
|
-
const objectHash = obj =>
|
|
19
|
+
const objectHash = (obj) =>
|
|
20
20
|
obj.singular || obj.name || obj.fieldName || obj.type || obj
|
|
21
21
|
const Differ = jsondiffpatch.create({
|
|
22
22
|
objectHash,
|
|
23
|
-
propertyFilter: name => name !== 'href' && name !== 'apiEndpoint',
|
|
23
|
+
propertyFilter: (name) => name !== 'href' && name !== 'apiEndpoint',
|
|
24
24
|
arrays: {
|
|
25
25
|
detectMove: true,
|
|
26
26
|
includeValueOnMove: true,
|
|
@@ -73,7 +73,7 @@ function sortSchemaObject(a, b) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function sortArrayProps(obj) {
|
|
76
|
-
Object.keys(obj).forEach(key => {
|
|
76
|
+
Object.keys(obj).forEach((key) => {
|
|
77
77
|
const val = obj[key]
|
|
78
78
|
if (Array.isArray(val)) {
|
|
79
79
|
const sorted = val.sort(sortSchemaObject)
|
|
@@ -210,7 +210,7 @@ async function run(args) {
|
|
|
210
210
|
})
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
const builder = yargs => {
|
|
213
|
+
const builder = (yargs) => {
|
|
214
214
|
yargs
|
|
215
215
|
.positional('leftUrl', {
|
|
216
216
|
type: 'string',
|
|
@@ -224,7 +224,7 @@ const builder = yargs => {
|
|
|
224
224
|
})
|
|
225
225
|
.option('base-url', {
|
|
226
226
|
alias: 'b',
|
|
227
|
-
coerce: opt => utils.prependHttpsProtocol(opt),
|
|
227
|
+
coerce: (opt) => utils.prependHttpsProtocol(opt),
|
|
228
228
|
describe: `BaseUrl to use for downloading schemas. If this is set leftServer and rightServer should be relative to this url, eg. /dev.`,
|
|
229
229
|
type: 'string',
|
|
230
230
|
})
|
package/src/cmds/schema/fetch.js
CHANGED
|
@@ -55,7 +55,7 @@ const command = {
|
|
|
55
55
|
},
|
|
56
56
|
'base-url': {
|
|
57
57
|
alias: 'b',
|
|
58
|
-
coerce: opt => prependHttpsProtocol(opt),
|
|
58
|
+
coerce: (opt) => prependHttpsProtocol(opt),
|
|
59
59
|
describe: `BaseUrl to use for downloading schemas. If this is set, urls that are relative (starts with /) will be appended to this url. eg. /dev.`,
|
|
60
60
|
type: 'string',
|
|
61
61
|
},
|
package/src/cmds/schema/index.js
CHANGED
|
@@ -19,12 +19,12 @@ const defaultRequestOpts = {
|
|
|
19
19
|
|
|
20
20
|
const prompt = inquirer.createPromptModule({ output: process.stderr })
|
|
21
21
|
|
|
22
|
-
const schemaIdentifier = info => `${info.version}_${info.revision}`
|
|
22
|
+
const schemaIdentifier = (info) => `${info.version}_${info.revision}`
|
|
23
23
|
const schemaDiffIdentifier = (info1, info2) =>
|
|
24
24
|
`${schemaIdentifier(info1)}__${schemaIdentifier(info2)}`
|
|
25
25
|
|
|
26
26
|
function asyncRequest(url, opts) {
|
|
27
|
-
return new Promise(resolve => {
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
28
|
request.get(url, opts, (err, res, body) => {
|
|
29
29
|
if (err || res.statusCode > 299) {
|
|
30
30
|
reporter.error('Request', url, 'failed to fetch')
|
package/src/cmds/schema.js
CHANGED
package/src/cmds/uid.js
CHANGED
|
@@ -17,7 +17,7 @@ const generateCmd = {
|
|
|
17
17
|
type: 'boolean',
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
-
handler: argv => {
|
|
20
|
+
handler: (argv) => {
|
|
21
21
|
const { limit } = argv
|
|
22
22
|
|
|
23
23
|
const codes = generateCodes(limit || 10)
|
|
@@ -44,7 +44,7 @@ const generateCmd = {
|
|
|
44
44
|
module.exports = namespace('uid', {
|
|
45
45
|
desc: 'DHIS2 UID tools',
|
|
46
46
|
aliases: 'u',
|
|
47
|
-
builder: yargs => {
|
|
47
|
+
builder: (yargs) => {
|
|
48
48
|
return yargs.command(generateCmd)
|
|
49
49
|
},
|
|
50
50
|
})
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@ const { namespace, createModuleLoader } = require('@dhis2/cli-helpers-engine')
|
|
|
2
2
|
|
|
3
3
|
const command = namespace('utils', {
|
|
4
4
|
desc: 'Utils for miscellaneous operations',
|
|
5
|
-
builder: yargs => {
|
|
5
|
+
builder: (yargs) => {
|
|
6
6
|
const loader = createModuleLoader({
|
|
7
7
|
parentModule: __filename,
|
|
8
8
|
})
|
|
@@ -3,14 +3,14 @@ const { reporter } = require('@dhis2/cli-helpers-engine')
|
|
|
3
3
|
const glob = require('glob')
|
|
4
4
|
|
|
5
5
|
// Simplified from https://github.com/yarnpkg/yarn/blob/bb9741af4d1fe00adb15e4a7596c7a3472d0bda3/src/config.js#L814
|
|
6
|
-
const globPackageFilePattern = pattern =>
|
|
6
|
+
const globPackageFilePattern = (pattern) =>
|
|
7
7
|
glob.sync(
|
|
8
8
|
path.join(process.cwd(), pattern.replace(/\/?$/, '/package.json')),
|
|
9
9
|
{
|
|
10
10
|
ignore: pattern.replace(/\/?$/, '/node_modules/**/package.json'),
|
|
11
11
|
}
|
|
12
12
|
)
|
|
13
|
-
const getWorkspacePackages = async packageFile => {
|
|
13
|
+
const getWorkspacePackages = async (packageFile) => {
|
|
14
14
|
try {
|
|
15
15
|
const rootPackage = require(packageFile)
|
|
16
16
|
if (rootPackage.workspaces) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
3
|
|
|
4
|
-
const normalizeAndValidatePackages = packages => {
|
|
4
|
+
const normalizeAndValidatePackages = (packages) => {
|
|
5
5
|
const errors = []
|
|
6
6
|
const validPackages = []
|
|
7
7
|
|
|
8
|
-
packages.forEach(packagePath => {
|
|
8
|
+
packages.forEach((packagePath) => {
|
|
9
9
|
let pkgJsonPath
|
|
10
10
|
if (!fs.existsSync(packagePath)) {
|
|
11
11
|
errors.push(`Path ${packagePath} does not exist`)
|
|
@@ -21,7 +21,7 @@ const verifyConditions = (config = {}, context) => {
|
|
|
21
21
|
throw new AggregateError(errors)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
validPackages.forEach(pkg => {
|
|
24
|
+
validPackages.forEach((pkg) => {
|
|
25
25
|
pkg.label = pkg.json.name || '<unnamed>'
|
|
26
26
|
if (!silent) {
|
|
27
27
|
logger.log(`Package ${pkg.label} found at ${pkg.path}`)
|
|
@@ -33,8 +33,8 @@ const verifyConditions = (config = {}, context) => {
|
|
|
33
33
|
|
|
34
34
|
const replaceDependencies = ({ pkg, listNames, packageNames, version }) => {
|
|
35
35
|
const dependencies = []
|
|
36
|
-
packageNames.forEach(packageName => {
|
|
37
|
-
listNames.forEach(listName => {
|
|
36
|
+
packageNames.forEach((packageName) => {
|
|
37
|
+
listNames.forEach((listName) => {
|
|
38
38
|
if (pkg[listName] && pkg[listName][packageName]) {
|
|
39
39
|
pkg[listName][packageName] = version
|
|
40
40
|
dependencies.push(`${packageName} (${listName})`)
|
|
@@ -55,8 +55,8 @@ const prepare = (config, context) => {
|
|
|
55
55
|
? nextRelease.version
|
|
56
56
|
: `^${nextRelease.version}`
|
|
57
57
|
|
|
58
|
-
const names = packages.map(pkg => pkg.json.name).filter(n => n)
|
|
59
|
-
packages.forEach(pkg => {
|
|
58
|
+
const names = packages.map((pkg) => pkg.json.name).filter((n) => n)
|
|
59
|
+
packages.forEach((pkg) => {
|
|
60
60
|
const pkgJson = pkg.json
|
|
61
61
|
const relativePath = path.relative(context.cwd, pkg.path)
|
|
62
62
|
|
|
@@ -75,7 +75,7 @@ const prepare = (config, context) => {
|
|
|
75
75
|
packageNames: names,
|
|
76
76
|
version: targetVersion,
|
|
77
77
|
}).forEach(
|
|
78
|
-
dep =>
|
|
78
|
+
(dep) =>
|
|
79
79
|
!silent &&
|
|
80
80
|
logger.log(
|
|
81
81
|
`Upgraded dependency ${dep}@${targetVersion} for ${pkg.label} at ${relativePath}`
|