@carbon/cli 11.32.0-rc.0 → 11.32.0-rc.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.
@@ -1,18 +1,16 @@
1
1
  /**
2
- * Copyright IBM Corp. 2019, 2023
2
+ * Copyright IBM Corp. 2019, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
9
-
10
- const chalk = require('chalk');
11
- const { exec } = require('child-process-promise');
12
- const { prompt } = require('inquirer');
13
- const path = require('path');
14
- const createLogger = require('progress-estimator');
15
- const getGitHubClient = require('./tools/getGitHubClient');
8
+ import chalk from 'chalk';
9
+ import { exec } from 'child-process-promise';
10
+ import inquirer from 'inquirer';
11
+ import path from 'path';
12
+ import createLogger from 'progress-estimator';
13
+ import getGitHubClient from './tools/getGitHubClient.js';
16
14
 
17
15
  const logger = createLogger();
18
16
 
@@ -22,13 +20,13 @@ chalk.dimmed = chalk.dim.italic;
22
20
  async function setup() {
23
21
  console.log(chalk`
24
22
  {bold Hi there!} 👋
25
- This tools is built for people looking to contribute to carbon.`);
23
+ This tool is built for people looking to contribute to carbon.`);
26
24
 
27
25
  if (!process.env.GH_TOKEN) {
28
26
  console.log(chalk`
29
27
  To get started, you will need a GitHub account {link (https://github.com/)}
30
28
 
31
- Once you have an account you will need to setup a GitHub access token
29
+ Once you have an account you will need to set up a GitHub access token
32
30
  {link (https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)}
33
31
  `);
34
32
  }
@@ -43,7 +41,7 @@ Once you have an account you will need to setup a GitHub access token
43
41
  Our first step is going to be to create a fork for each project you want to work on.
44
42
  `);
45
43
 
46
- const { projects } = await prompt([
44
+ const { projects } = await inquirer.prompt([
47
45
  {
48
46
  type: 'checkbox',
49
47
  name: 'projects',
@@ -81,11 +79,11 @@ async function fork(client, cwd, project) {
81
79
  );
82
80
 
83
81
  console.log(
84
- `Your fork is done! Now let's setup the project on your computer.`
82
+ `Your fork is done! Now let's set up the project on your computer.`
85
83
  );
86
84
  console.log();
87
85
 
88
- const { folder } = await prompt([
86
+ const { folder } = await inquirer.prompt([
89
87
  {
90
88
  type: 'input',
91
89
  name: 'folder',
@@ -223,8 +221,6 @@ const availableProjects = [
223
221
  },
224
222
  ];
225
223
 
226
- module.exports = {
227
- command: 'setup',
228
- desc: 'setup your environment',
229
- handler: wrap(setup),
230
- };
224
+ export const command = 'setup';
225
+ export const desc = 'setup your environment';
226
+ export const handler = wrap(setup);
@@ -5,17 +5,15 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
9
-
10
- const Octokit = require('@octokit/rest');
11
- const { prompt } = require('inquirer');
8
+ import inquirer from 'inquirer';
9
+ import { Octokit } from '@octokit/rest';
12
10
 
13
11
  const CustomOctokit = Octokit.plugin([
14
- require('@octokit/plugin-throttling'),
15
- require('@octokit/plugin-retry'),
12
+ import('@octokit/plugin-throttling'),
13
+ import('@octokit/plugin-retry'),
16
14
  ]);
17
15
 
18
- async function getGitHubClient() {
16
+ export default async function getGitHubClient() {
19
17
  let { GH_TOKEN } = process.env;
20
18
 
21
19
  if (!GH_TOKEN) {
@@ -27,7 +25,7 @@ async function getGitHubClient() {
27
25
  hint: 'Help: https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line',
28
26
  },
29
27
  ];
30
- const answers = await prompt(question);
28
+ const answers = await inquirer.prompt(question);
31
29
  GH_TOKEN = answers.token;
32
30
  }
33
31
 
@@ -67,5 +65,3 @@ async function getGitHubClient() {
67
65
  throw new Error('Invalid GitHub token');
68
66
  }
69
67
  }
70
-
71
- module.exports = getGitHubClient;
@@ -1,16 +1,13 @@
1
1
  /**
2
- * Copyright IBM Corp. 2019, 2023
2
+ * Copyright IBM Corp. 2019, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
8
+ export const command = 'contribute <command>';
9
+ export const desc = 'get started contributing with Carbon';
9
10
 
10
- module.exports = {
11
- command: 'contribute <command>',
12
- desc: 'get started contributing with Carbon',
13
- builder(yargs) {
14
- yargs.commandDir('contribute');
15
- },
11
+ export const builder = (yargs) => {
12
+ yargs.commandDir('contribute');
16
13
  };
@@ -1,18 +1,16 @@
1
1
  /**
2
- * Copyright IBM Corp. 2019, 2023
2
+ * Copyright IBM Corp. 2019, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
9
-
10
- const fs = require('fs-extra');
11
- const klaw = require('klaw-sync');
12
- const os = require('os');
13
- const path = require('path');
14
- const replace = require('replace-in-file');
15
- const { createLogger } = require('../logger');
8
+ import fs from 'fs-extra';
9
+ import klaw from 'klaw-sync';
10
+ import os from 'os';
11
+ import path from 'path';
12
+ import { replaceInFile } from 'replace-in-file';
13
+ import { createLogger } from '../logger.js';
16
14
 
17
15
  const logger = createLogger('inline');
18
16
  const isWin = process.platform === 'win32';
@@ -121,7 +119,7 @@ async function inlineSassDependencies(
121
119
  vendorFolder
122
120
  );
123
121
 
124
- await replace({
122
+ await replaceInFile({
125
123
  files: file.path,
126
124
  from: REPLACE_REGEX,
127
125
  glob: { windowsPathsNoEscape: true },
@@ -154,18 +152,18 @@ function findSassModule(packageName, cwd) {
154
152
  return false;
155
153
  }
156
154
 
157
- module.exports = {
158
- command: 'inline',
159
- desc: 'inline sass dependencies from package.json in a target folder',
160
- builder(yargs) {
161
- yargs.options({
162
- o: {
163
- alias: 'output',
164
- describe: 'the directory to output inlined sass dependencies',
165
- type: 'string',
166
- default: 'scss',
167
- },
168
- });
169
- },
170
- handler: inline,
155
+ export const builder = (yargs) => {
156
+ yargs.options({
157
+ o: {
158
+ alias: 'output',
159
+ describe: 'the directory to output inlined sass dependencies',
160
+ type: 'string',
161
+ default: 'scss',
162
+ },
163
+ });
171
164
  };
165
+
166
+ export const command = 'inline';
167
+ export const desc =
168
+ 'inline sass dependencies from package.json in a target folder';
169
+ export const handler = inline;
@@ -1,27 +1,27 @@
1
1
  /**
2
- * Copyright IBM Corp. 2019, 2023
2
+ * Copyright IBM Corp. 2019, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
9
-
10
- const execa = require('execa');
11
- const { prompt } = require('inquirer');
12
- const semver = require('semver');
13
- const { generate } = require('../changelog');
14
- const { fetchLatestFromUpstream } = require('../git');
15
- const { createLogger, displayBanner } = require('../logger');
16
- const { getPackages } = require('../workspace');
8
+ import { execa } from 'execa';
9
+ import inquirer from 'inquirer';
10
+ import semver from 'semver';
11
+ import { generate } from '../changelog.js';
12
+ import { fetchLatestFromUpstream } from '../git.js';
13
+ import { createLogger, displayBanner } from '../logger.js';
14
+ import { getPackages } from '../workspace.js';
17
15
 
18
16
  const logger = createLogger('publish');
17
+
19
18
  // Enqueue tasks to run at the end of the command where we want to "clean-up"
20
19
  // the environment
21
20
  const deferred = [];
22
21
  function defer(thunk) {
23
22
  deferred.push(thunk);
24
23
  }
24
+
25
25
  async function cleanup() {
26
26
  for (let i = deferred.length - 1; i >= 0; i--) {
27
27
  const task = deferred[i];
@@ -144,7 +144,7 @@ async function publish({ tag, ...flags }) {
144
144
 
145
145
  // We specify a stopping point so that the operator can verify the packages
146
146
  // published as intended before setting the `latest` dist-tag
147
- const answers = await prompt([
147
+ const answers = await inquirer.prompt([
148
148
  {
149
149
  type: 'confirm',
150
150
  name: 'tags',
@@ -170,7 +170,7 @@ async function publish({ tag, ...flags }) {
170
170
  }
171
171
 
172
172
  if (!noPush) {
173
- const { remote } = await prompt([
173
+ const { remote } = await inquirer.prompt([
174
174
  {
175
175
  type: 'confirm',
176
176
  name: 'remote',
@@ -191,7 +191,7 @@ async function publish({ tag, ...flags }) {
191
191
  const changelog = await generate(packages, lastTag, tag);
192
192
  logger.stop();
193
193
 
194
- const { display } = await prompt([
194
+ const { display } = await inquirer.prompt([
195
195
  {
196
196
  type: 'confirm',
197
197
  name: 'display',
@@ -218,55 +218,55 @@ async function getLastGitTag() {
218
218
  return tags[0];
219
219
  }
220
220
 
221
- module.exports = {
222
- command: 'publish <tag>',
223
- desc: 'publish packages that have different versions from the package registry',
224
- builder(yargs) {
225
- yargs.positional('tag', {
226
- describe: 'the version tag associated with the release',
227
- type: 'string',
228
- });
229
-
230
- yargs.option('skip-reset', {
231
- demandOption: false,
232
- default: false,
233
- describe: 'Skip the project reset step',
234
- type: 'boolean',
235
- });
236
-
237
- yargs.option('registry', {
238
- demandOption: false,
239
- describe: 'Specify registry URL',
240
- default: 'https://registry.npmjs.org/',
241
- type: 'string',
242
- });
243
-
244
- yargs.option('no-git-tag-version', {
245
- demandOption: false,
246
- describe: 'Do not commit or tag version changes.',
247
- default: false,
248
- type: 'boolean',
249
- });
250
-
251
- yargs.option('git-remote', {
252
- demandOption: false,
253
- describe: 'Push git changes to the specified remote.',
254
- default: 'upstream',
255
- type: 'string',
256
- });
221
+ export const builder = (yargs) => {
222
+ yargs.positional('tag', {
223
+ describe: 'the version tag associated with the release',
224
+ type: 'string',
225
+ });
226
+
227
+ yargs.option('skip-reset', {
228
+ demandOption: false,
229
+ default: false,
230
+ describe: 'Skip the project reset step',
231
+ type: 'boolean',
232
+ });
233
+
234
+ yargs.option('registry', {
235
+ demandOption: false,
236
+ describe: 'Specify registry URL',
237
+ default: 'https://registry.npmjs.org/',
238
+ type: 'string',
239
+ });
240
+
241
+ yargs.option('no-git-tag-version', {
242
+ demandOption: false,
243
+ describe: 'Do not commit or tag version changes.',
244
+ default: false,
245
+ type: 'boolean',
246
+ });
247
+
248
+ yargs.option('git-remote', {
249
+ demandOption: false,
250
+ describe: 'Push git changes to the specified remote.',
251
+ default: 'upstream',
252
+ type: 'string',
253
+ });
254
+
255
+ yargs.option('no-push', {
256
+ demandOption: false,
257
+ describe: 'Do not push tagged commit to git remote.',
258
+ default: false,
259
+ type: 'boolean',
260
+ });
261
+ };
257
262
 
258
- yargs.option('no-push', {
259
- demandOption: false,
260
- describe: 'Do not push tagged commit to git remote.',
261
- default: false,
262
- type: 'boolean',
263
- });
264
- },
265
- async handler(...args) {
266
- try {
267
- await publish(...args);
268
- } finally {
269
- await cleanup();
270
- }
271
- },
263
+ export const command = 'publish <tag>';
264
+ export const desc =
265
+ 'publish packages that have different versions from the package registry';
266
+ export const handler = async (...args) => {
267
+ try {
268
+ await publish(...args);
269
+ } finally {
270
+ await cleanup();
271
+ }
272
272
  };
@@ -1,18 +1,16 @@
1
1
  /**
2
- * Copyright IBM Corp. 2019, 2023
2
+ * Copyright IBM Corp. 2019, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
9
-
10
- const parse = require('@commitlint/parse');
11
- const execa = require('execa');
12
- const { prompt } = require('inquirer');
13
- const semver = require('semver');
14
- const { fetchLatestFromUpstream } = require('../git');
15
- const { createLogger, displayBanner } = require('../logger');
8
+ import parse from '@commitlint/parse';
9
+ import { execa } from 'execa';
10
+ import inquirer from 'inquirer';
11
+ import semver from 'semver';
12
+ import { fetchLatestFromUpstream } from '../git.js';
13
+ import { createLogger, displayBanner } from '../logger.js';
16
14
 
17
15
  // All supported commit types from our conventional-changelog preset
18
16
  const types = [
@@ -166,7 +164,7 @@ async function cherryPickCommitsFrom(commitRange, bump) {
166
164
  // If we cannot derive the commit type, we'll need to manually confirm if we
167
165
  // should include the commit
168
166
  if (info.type === null) {
169
- const answers = await prompt([
167
+ const answers = await inquirer.prompt([
170
168
  {
171
169
  type: 'confirm',
172
170
  name: 'confirmed',
@@ -207,7 +205,7 @@ async function cherryPickCommitsFrom(commitRange, bump) {
207
205
  if (!error.stderr.startsWith('error: could not apply')) {
208
206
  throw error;
209
207
  }
210
- const answers = await prompt([
208
+ const answers = await inquirer.prompt([
211
209
  {
212
210
  type: 'confirm',
213
211
  name: 'proceed',
@@ -267,7 +265,7 @@ async function resetProjectState() {
267
265
  async function checkIfBranchIsDirty() {
268
266
  const { stdout } = await execa('git', ['status', '--porcelain']);
269
267
  if (stdout !== '') {
270
- const { confirmed } = await prompt([
268
+ const { confirmed } = await inquirer.prompt([
271
269
  {
272
270
  type: 'confirm',
273
271
  name: 'confirmed',
@@ -288,15 +286,14 @@ async function checkIfBranchIsDirty() {
288
286
  }
289
287
  }
290
288
 
291
- module.exports = {
292
- command: 'release [bump]',
293
- desc: 'run the release step for the given version bump',
294
- builder(yargs) {
295
- yargs.positional('bump', {
296
- describe: 'choose a release version to bump',
297
- choices: ['minor', 'patch'],
298
- default: 'patch',
299
- });
300
- },
301
- handler: release,
289
+ export const builder = (yargs) => {
290
+ yargs.positional('bump', {
291
+ describe: 'choose a release version to bump',
292
+ choices: ['minor', 'patch'],
293
+ default: 'patch',
294
+ });
302
295
  };
296
+
297
+ export const command = 'release [bump]';
298
+ export const desc = 'run the release step for the given version bump';
299
+ export const handler = release;
@@ -1,14 +1,12 @@
1
1
  /**
2
- * Copyright IBM Corp. 2019, 2023
2
+ * Copyright IBM Corp. 2019, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
9
-
10
- const fs = require('fs-extra');
11
- const path = require('path');
8
+ import fs from 'fs-extra';
9
+ import path from 'path';
12
10
 
13
11
  const defaultIgnorePatterns = [
14
12
  '**/__mocks__/**',
@@ -17,7 +15,7 @@ const defaultIgnorePatterns = [
17
15
  '**/tasks/**',
18
16
  ];
19
17
 
20
- function run({ packagePaths }) {
18
+ export default async function run({ packagePaths }) {
21
19
  return Promise.all(
22
20
  packagePaths.map(async ({ packagePath }) => {
23
21
  const ignorePath = path.join(packagePath, '.npmignore');
@@ -37,7 +35,4 @@ function run({ packagePaths }) {
37
35
  );
38
36
  }
39
37
 
40
- module.exports = {
41
- name: 'npm',
42
- run,
43
- };
38
+ export const name = 'npm';
@@ -1,13 +1,11 @@
1
1
  /**
2
- * Copyright IBM Corp. 2019, 2023
2
+ * Copyright IBM Corp. 2019, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
9
-
10
- const fs = require('fs-extra');
8
+ import fs from 'fs-extra';
11
9
 
12
10
  // This is our default set of keywords to include in each `package.json` packageJson
13
11
  const DEFAULT_KEYWORDS = [
@@ -69,7 +67,7 @@ function sortFields(a, b) {
69
67
  return aValue - bValue;
70
68
  }
71
69
 
72
- function run({ packagePaths }) {
70
+ export default async function run({ packagePaths }) {
73
71
  return Promise.all(
74
72
  packagePaths.map(
75
73
  async ({ packageJsonPath, packageJson, packageFolder }) => {
@@ -117,7 +115,4 @@ function run({ packagePaths }) {
117
115
  );
118
116
  }
119
117
 
120
- module.exports = {
121
- name: 'package',
122
- run,
123
- };
118
+ export const name = 'package';
@@ -1,18 +1,16 @@
1
1
  /**
2
- * Copyright IBM Corp. 2019, 2023
2
+ * Copyright IBM Corp. 2019, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
9
-
10
- const fs = require('fs-extra');
11
- const path = require('path');
12
- const prettier = require('prettier2');
13
- const prettierConfig = require('prettier-config-carbon');
14
- const createRemark = require('remark');
15
- const monorepo = require('./remark/remark-monorepo');
8
+ import fs from 'fs-extra';
9
+ import path from 'path';
10
+ import prettier from 'prettier';
11
+ import prettierConfig from 'prettier-config-carbon';
12
+ import { remark } from 'remark';
13
+ import monorepo from './remark/remark-monorepo.js';
16
14
 
17
15
  const packageDenyList = new Set([
18
16
  'carbon-components',
@@ -21,8 +19,8 @@ const packageDenyList = new Set([
21
19
  '@carbon/styles',
22
20
  ]);
23
21
 
24
- function run({ root, packagePaths }) {
25
- const remark = createRemark().use(monorepo, {
22
+ export default async function run({ root, packagePaths }) {
23
+ const remarkInstance = remark().use(monorepo, {
26
24
  root: root.directory,
27
25
  });
28
26
  const prettierOptions = {
@@ -40,7 +38,7 @@ function run({ root, packagePaths }) {
40
38
  }
41
39
 
42
40
  const readme = await fs.readFile(README_PATH, 'utf8');
43
- const file = await process(remark, packagePath, readme);
41
+ const file = await process(remarkInstance, packagePath, readme);
44
42
  await fs.writeFile(
45
43
  README_PATH,
46
44
  prettier.format(String(file), prettierOptions)
@@ -49,9 +47,9 @@ function run({ root, packagePaths }) {
49
47
  );
50
48
  }
51
49
 
52
- function process(remark, cwd, contents) {
50
+ function process(remarkInstance, cwd, contents) {
53
51
  return new Promise((resolve, reject) => {
54
- remark.process({ cwd, contents }, (error, file) => {
52
+ remarkInstance.process({ cwd, contents }, (error, file) => {
55
53
  if (error) {
56
54
  reject(error);
57
55
  return;
@@ -61,7 +59,4 @@ function process(remark, cwd, contents) {
61
59
  });
62
60
  }
63
61
 
64
- module.exports = {
65
- name: 'readme',
66
- run,
67
- };
62
+ export const name = 'readme';
@@ -1,16 +1,14 @@
1
1
  /**
2
- * Copyright IBM Corp. 2018, 2023
2
+ * Copyright IBM Corp. 2019, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- 'use strict';
8
+ import fs from 'fs-extra';
9
+ import path from 'path';
9
10
 
10
- const fs = require('fs-extra');
11
- const path = require('path');
12
-
13
- function monorepo() {
11
+ export default function monorepo() {
14
12
  async function transformer(tree, file) {
15
13
  const { cwd } = file;
16
14
  const localPackageJsonPath = path.join(cwd, 'package.json');
@@ -421,5 +419,3 @@ function createLicense() {
421
419
  },
422
420
  ];
423
421
  }
424
-
425
- module.exports = monorepo;