@dhis2/cli-utils 5.2.0-alpha.8 → 5.2.0

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 CHANGED
@@ -6,7 +6,7 @@
6
6
  "engines": {
7
7
  "node": ">=12"
8
8
  },
9
- "version": "5.2.0-alpha.8",
9
+ "version": "5.2.0",
10
10
  "main": "src/index.js",
11
11
  "author": "Viktor Varland <viktor@dhis2.org>",
12
12
  "contributors": [
@@ -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
  {
@@ -71,15 +71,15 @@ const handler = async ({ publish }) => {
71
71
  {
72
72
  assets: [
73
73
  'CHANGELOG.md',
74
- packages.map(pkgJsonPath =>
74
+ packages.map((pkgJsonPath) =>
75
75
  path.relative(process.cwd(), pkgJsonPath)
76
76
  ),
77
77
  packages
78
- .map(pkgJsonPath =>
78
+ .map((pkgJsonPath) =>
79
79
  path.join(path.dirname(pkgJsonPath), 'pnpm-lock.yaml')
80
80
  )
81
81
  .filter(existsSync)
82
- .map(pkgJsonPath =>
82
+ .map((pkgJsonPath) =>
83
83
  path.relative(process.cwd(), pkgJsonPath)
84
84
  ),
85
85
  ],
@@ -91,7 +91,8 @@ const handler = async ({ publish }) => {
91
91
  const updateLockFile = [
92
92
  '@semantic-release/exec',
93
93
  {
94
- publishCmd: 'pnpm install --lockfile-only', // ToDo: make it independent of npm
94
+ publishCmd:
95
+ 'pnpm install --lockfile-only && git commit -am "chore: bump pnpm-lock.yml ${nextRelease.version} [skip ci]" && git push',
95
96
  },
96
97
  ]
97
98
  const deferPlugin = require('../support/semantic-release-defer-release')
@@ -110,19 +111,7 @@ const handler = async ({ publish }) => {
110
111
  [
111
112
  '@semantic-release/git',
112
113
  {
113
- assets: [
114
- packages
115
- .map(pkgJsonPath =>
116
- path.join(
117
- path.dirname(pkgJsonPath),
118
- 'pnpm-lock.yaml'
119
- )
120
- )
121
- .filter(existsSync)
122
- .map(pkgJsonPath =>
123
- path.relative(process.cwd(), pkgJsonPath)
124
- ),
125
- ],
114
+ assets: ['pnpm-lock.yaml'],
126
115
  message:
127
116
  'chore: bump pnpm-lock.yml ${nextRelease.version} [skip ci]',
128
117
  },
@@ -135,7 +124,7 @@ const handler = async ({ publish }) => {
135
124
  * https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md
136
125
  */
137
126
  const options = {
138
- plugins: plugins.filter(n => !!n),
127
+ plugins: plugins.filter((n) => !!n),
139
128
  }
140
129
 
141
130
  const config = {
@@ -146,7 +135,6 @@ const handler = async ({ publish }) => {
146
135
  }
147
136
 
148
137
  try {
149
- console.log(semanticRelease)
150
138
  const result = await semanticRelease(options, config)
151
139
 
152
140
  if (result) {
@@ -188,5 +176,3 @@ module.exports = {
188
176
  },
189
177
  },
190
178
  }
191
-
192
- // 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
  })
@@ -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
  },
@@ -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')
@@ -2,7 +2,7 @@ const { namespace } = require('@dhis2/cli-helpers-engine')
2
2
 
3
3
  const command = namespace('schema', {
4
4
  desc: 'Utils for schema operations',
5
- builder: yargs =>
5
+ builder: (yargs) =>
6
6
  yargs
7
7
  .option('force', {
8
8
  type: 'boolean',
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}`