@carbon/cli 11.27.0 → 11.28.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/cli",
3
3
  "description": "Task automation for working with the Carbon Design System",
4
- "version": "11.27.0",
4
+ "version": "11.28.0",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
7
7
  "carbon-cli": "./bin/carbon-cli.js"
@@ -27,7 +27,7 @@
27
27
  "postinstall": "ibmtelemetry --config=telemetry.yml"
28
28
  },
29
29
  "dependencies": {
30
- "@babel/core": "^7.24.7",
30
+ "@babel/core": "^7.27.3",
31
31
  "@carbon/cli-reporter": "^10.7.0",
32
32
  "@ibm/telemetry-js": "^1.5.0",
33
33
  "@octokit/plugin-retry": "^3.0.7",
@@ -46,7 +46,6 @@
46
46
  "inquirer": "^6.4.1",
47
47
  "klaw-sync": "^6.0.0",
48
48
  "lodash.template": "^4.5.0",
49
- "markdown-toc": "^1.2.0",
50
49
  "prettier": "^3.3.3",
51
50
  "prettier-config-carbon": "^0.11.0",
52
51
  "progress-estimator": "^0.3.0",
@@ -54,9 +53,8 @@
54
53
  "replace-in-file": "^7.0.0",
55
54
  "rollup": "^2.79.1",
56
55
  "sass": "^1.77.7",
57
- "sassdoc": "^2.7.3",
58
56
  "typescript-config-carbon": "^0.5.0",
59
57
  "yargs": "^17.0.1"
60
58
  },
61
- "gitHead": "ec31b96c91af8208499180eaeae89eb08b7ac8c8"
59
+ "gitHead": "f6debacbfe06fa5c31f70809e15762dc30096d70"
62
60
  }
@@ -1,405 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2018, 2023
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- 'use strict';
9
-
10
- const prettier = require('prettier2');
11
- const sassdoc = require('sassdoc');
12
- const toc = require('markdown-toc');
13
-
14
- const prettierOptions = {
15
- parser: 'markdown',
16
- printWidth: 80,
17
- singleQuote: true,
18
- trailingComma: 'es5',
19
- proseWrap: 'always',
20
- };
21
-
22
- /**
23
- * Custom slugify for markdown-toc to not include escaped emoji characters
24
- * @param {string} title - the anchor link
25
- */
26
- const slugify = (title) => {
27
- return [...toc.slugify(title)].reduce((acc, ch) => {
28
- if (ch.charCodeAt(0) > 255) {
29
- return acc;
30
- }
31
- return acc + ch;
32
- }, '');
33
- };
34
-
35
- /**
36
- * Create a JSON file of documented Sass items
37
- * @see {@link http://sassdoc.com/configuration/|Sassdoc configuration}
38
- * @param {string} sourceDir - source directory
39
- * @param {object} config - configuration object
40
- * @returns {object} json object
41
- */
42
- async function createJson(sourceDir, config) {
43
- config = config || {};
44
-
45
- return sassdoc.parse(sourceDir, config).then(
46
- (data) => {
47
- return data;
48
- },
49
- (err) => {
50
- console.error(err);
51
- }
52
- );
53
- }
54
-
55
- /**
56
- * Remove duplicate objects in `require` and `usedBy` arrays. Array objects have
57
- * `name` and `type` properties, sometimes nested in a `context` object.
58
- * @param {Array} arr - array with potential duplicates
59
- * @returns {Array} deduped array
60
- */
61
- function dedupeArray(arr) {
62
- return arr.reduce(
63
- (p, item) => {
64
- const type = item.type || item.context.type;
65
- const name = item.name || item.context.name;
66
- const id = [type, name].join('|');
67
-
68
- if (p.temp.indexOf(id) === -1) {
69
- p.out.push(item);
70
- p.temp.push(id);
71
- }
72
- return p;
73
- },
74
- { temp: [], out: [] }
75
- ).out;
76
- }
77
-
78
- /**
79
- * Create a unique Sassdoc item name
80
- * @param {string} name - Sassdoc name
81
- * @param {string} type - Sassdoc type (e.g. `variable`, `mixin`)
82
- * @returns {string} unique Sassdoc item name
83
- */
84
- function createUniqueName(name, type) {
85
- return `${name} [${type}]`;
86
- }
87
-
88
- /**
89
- * Create a standardized group name
90
- * @param {Array} group - Item's group
91
- * @returns {string} group name
92
- */
93
- function createGroupName(group) {
94
- return !group || !group[0] || group[0] === 'undefined' ? 'general' : group[0];
95
- }
96
-
97
- /**
98
- * Create GitHub-flavored markdown anchor link
99
- * @param {string} name - anchor value
100
- * @param {string} heading - anchor link destination
101
- * @returns {string} markdown anchor
102
- */
103
- function createAnchorLink(name, heading) {
104
- const anchorLink = heading
105
- .toLowerCase()
106
- .replace(/ /g, '-')
107
- .replace(/[`~!@#$%^&*()+=<>?,./:;"'|{}[\]\\–—]/g, '')
108
- .replace(
109
- // eslint-disable-next-line no-irregular-whitespace
110
- /[ 。?!,、;:“”【】()〔〕[]﹃﹄“”‘’﹁﹂—…-~《》〈〉「」]/g,
111
- ''
112
- );
113
-
114
- return `[${name}](#${anchorLink})`;
115
- }
116
-
117
- /**
118
- * Create markdown for Sassdoc item (function, mixin, placeholder, variable)
119
- * @param {string} item - Sassdoc item
120
- * @returns {string} item in markdown formatting
121
- */
122
- function createMarkdownItem(item) {
123
- let str = '';
124
-
125
- if (!item.context) {
126
- return '';
127
- }
128
-
129
- let status = item.access === 'public' ? '✅' : '❌';
130
-
131
- if (item.deprecated || item.deprecated === '') {
132
- status += '⚠️';
133
- }
134
-
135
- // Name
136
- str += `\n\n### ${status}${createUniqueName(
137
- item.context.name,
138
- item.context.type
139
- )}`;
140
-
141
- // Description
142
- if (item.description) {
143
- str += `\n\n${item.description.trim()}`;
144
- }
145
-
146
- // Value (variables)
147
- if (item.context.value) {
148
- str += `
149
-
150
- <details>
151
- <summary>Source code</summary>
152
-
153
- \`\`\`scss
154
- $${item.context.name}: ${item.context.value};
155
- \`\`\`
156
- </details>`;
157
- }
158
-
159
- // Code (mixins)
160
- if (item.context.code) {
161
- let paramStr = '';
162
-
163
- if (item.parameter) {
164
- item.parameter.forEach((param) => {
165
- if (paramStr) {
166
- paramStr += `, `;
167
- }
168
- paramStr += `$${param.name}`;
169
- if (param.default) {
170
- paramStr += `: ${param.default}`;
171
- }
172
- });
173
- }
174
-
175
- str += `
176
-
177
- <details>
178
- <summary>Source code</summary>
179
-
180
- \`\`\`scss
181
- @${item.context.type} ${item.context.name}(${paramStr}) {${item.context.code}}
182
- \`\`\`
183
- </details>`;
184
- }
185
-
186
- // Parameters
187
- if (item.parameter && item.parameter.length) {
188
- str += `
189
-
190
- - **Parameters**:
191
-
192
- | Name | Description | Type | Default value |
193
- | --- | --- | --- | --- |`;
194
-
195
- item.parameter.forEach((param) => {
196
- const paramType = param.type
197
- ? `\`${param.type.replace(/\|/g, `\\|`)}\``
198
- : '—';
199
- const paramDefault = param.default ? `\`${param.default}\`` : '—';
200
-
201
- const row = `\n| \`$${param.name}\` | ${
202
- param.description || '—'
203
- } | ${paramType} | ${paramDefault} |`;
204
-
205
- str += row;
206
- });
207
- }
208
-
209
- // Example
210
- if (item.example && item.example.length) {
211
- str += `\n\n**Example**:`;
212
-
213
- if (item.example[0].description) {
214
- str += ` ${item.example[0].description}`;
215
- }
216
-
217
- str += `
218
-
219
- <details>
220
- <summary>Example code</summary>
221
-
222
- \`\`\`${item.example[0].type}
223
- ${item.example[0].code}
224
- \`\`\`
225
- </details>`;
226
- }
227
-
228
- // Bullets
229
- const metadata = [];
230
-
231
- const groupName = createGroupName(item.group);
232
-
233
- metadata.push({
234
- key: 'Group',
235
- value: createAnchorLink(groupName, groupName),
236
- });
237
-
238
- if (item.return) {
239
- metadata.push({
240
- key: 'Returns',
241
- value: `\`${item.return.type}\` ${item.return.description || ''}`,
242
- });
243
- }
244
-
245
- if (item.type) {
246
- metadata.push({
247
- key: 'Type',
248
- value: `\`${item.type}\``,
249
- });
250
- }
251
-
252
- if (item.alias) {
253
- metadata.push({
254
- key: 'Alias',
255
- value: `\`${item.alias}\``,
256
- });
257
- }
258
-
259
- if (item.aliased) {
260
- let subbullets = '';
261
-
262
- item.aliased.forEach((aliased) => {
263
- subbullets += `\n - \`${aliased}\``;
264
- });
265
-
266
- metadata.push({
267
- key: 'Aliased',
268
- value: subbullets,
269
- });
270
- }
271
-
272
- if (item.content) {
273
- metadata.push({
274
- key: 'Content',
275
- value: item.content,
276
- });
277
- }
278
-
279
- if (item.require && item.require.length) {
280
- let subbullets = '';
281
-
282
- dedupeArray(item.require).forEach((requires) => {
283
- subbullets += `\n - ${createAnchorLink(
284
- `${requires.name} [${requires.type}]`,
285
- createUniqueName(requires.name, requires.type)
286
- )}`;
287
- });
288
-
289
- metadata.push({
290
- key: 'Requires',
291
- value: subbullets,
292
- });
293
- }
294
-
295
- if (item.usedBy && item.usedBy.length) {
296
- let subbullets = '';
297
-
298
- dedupeArray(item.usedBy).forEach((usedBy) => {
299
- subbullets += `\n - ${createAnchorLink(
300
- `${usedBy.context.name} [${usedBy.context.type}]`,
301
- createUniqueName(usedBy.context.name, usedBy.context.type)
302
- )}`;
303
- });
304
-
305
- metadata.push({
306
- key: 'Used by',
307
- value: subbullets,
308
- });
309
- }
310
-
311
- // if (item.since && item.since.length) {
312
- // metadata.push({
313
- // key: 'Since',
314
- // value: item.since[0].version,
315
- // });
316
- // }
317
-
318
- if (item.link && item.link.length) {
319
- let subbullets = '';
320
-
321
- item.link.forEach((link) => {
322
- subbullets += `\n - [${link.caption || 'Link'}](${link.url})`;
323
- });
324
-
325
- metadata.push({
326
- key: 'Links',
327
- value: subbullets,
328
- });
329
- }
330
-
331
- if (item.deprecated || item.deprecated === '') {
332
- metadata.push({
333
- key: 'Deprecated',
334
- value: item.deprecated || 'This may not be available in future releases',
335
- });
336
- }
337
-
338
- if (metadata.length) {
339
- str += '\n';
340
-
341
- metadata.forEach((meta) => {
342
- str += `\n- **${meta.key}**: ${meta.value}`;
343
- });
344
- }
345
-
346
- return str;
347
- }
348
-
349
- /**
350
- * Create a markdown file of documented Sass items
351
- * @see {@link http://sassdoc.com/configuration/|Sassdoc configuration}
352
- * @param {string} sourceDir - source directory
353
- * @param {object} config - configuration object
354
- * @returns {string} markdown
355
- */
356
- async function createMarkdown(sourceDir, config) {
357
- config = config || {};
358
-
359
- return sassdoc.parse(sourceDir, config).then(
360
- (data) => {
361
- let markdownFile = '';
362
-
363
- const documentedItems = data.filter(
364
- (item) => item.access === 'public' || item.access === 'private'
365
- );
366
-
367
- markdownFile += `# Sass API
368
-
369
- | Mark | Description |
370
- | --- | --- |
371
- | ✅ | Public functions, mixins, placeholders, and variables |
372
- | ❌ | Private items - not supported outside package's build |
373
- | ⚠️ | Deprecated items - may not be available in future releases |
374
-
375
- <!-- toc -->
376
- <!-- tocstop -->`;
377
-
378
- let currentGroup = '';
379
-
380
- documentedItems.forEach((item) => {
381
- const itemGroup = createGroupName(item.group);
382
-
383
- if (itemGroup !== currentGroup) {
384
- markdownFile += `\n\n## ${itemGroup}`;
385
- currentGroup = itemGroup;
386
- }
387
-
388
- markdownFile += createMarkdownItem(item);
389
- });
390
-
391
- return prettier.format(
392
- toc.insert(markdownFile, { slugify }),
393
- prettierOptions
394
- );
395
- },
396
- (err) => {
397
- console.error(err);
398
- }
399
- );
400
- }
401
-
402
- module.exports = {
403
- createJson,
404
- createMarkdown,
405
- };
@@ -1,90 +0,0 @@
1
- /**
2
- * Copyright IBM Corp. 2019, 2023
3
- *
4
- * This source code is licensed under the Apache-2.0 license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- 'use strict';
9
-
10
- const glob = require('fast-glob');
11
- const fs = require('fs-extra');
12
- const path = require('path');
13
- const { createLogger } = require('../logger');
14
- const { createJson, createMarkdown } = require('./sassdoc/tools');
15
-
16
- const logger = createLogger('sassdoc');
17
-
18
- async function sassdoc({
19
- glob: pattern,
20
- ignore = [],
21
- json = false,
22
- output = 'docs',
23
- } = {}) {
24
- logger.start('sassdoc');
25
-
26
- const cwd = process.cwd();
27
- const DOCS_DIR = path.resolve(cwd, output);
28
- const JSON_FILE = path.resolve(DOCS_DIR, 'sass.json');
29
- const MARKDOWN_FILE = path.resolve(DOCS_DIR, 'sass.md');
30
- const files = await glob(pattern, {
31
- cwd,
32
- ignore,
33
- });
34
-
35
- logger.info(
36
- `Creating sassdoc for pattern: '${pattern}', ignoring: '${ignore}'`
37
- );
38
-
39
- if (json) {
40
- try {
41
- const jsonFile = await createJson(files);
42
- await fs.ensureDir(DOCS_DIR);
43
- await fs.writeFile(JSON_FILE, JSON.stringify(jsonFile, null, 2));
44
- } catch (error) {
45
- logger.info(`Sassdoc error: ${error}`);
46
- process.exit(1);
47
- }
48
- } else {
49
- try {
50
- const markdownFile = await createMarkdown(files);
51
- await fs.ensureDir(DOCS_DIR);
52
- await fs.writeFile(MARKDOWN_FILE, markdownFile);
53
- } catch (error) {
54
- logger.info(`Sassdoc error: ${error}`);
55
- process.exit(1);
56
- }
57
- }
58
-
59
- logger.stop();
60
- }
61
-
62
- module.exports = {
63
- command: 'sassdoc <glob>',
64
- desc: 'generate sassdoc as markdown',
65
- builder(yargs) {
66
- yargs.positional('glob', {
67
- type: 'string',
68
- describe: 'glob pattern for files to check',
69
- });
70
-
71
- yargs.options({
72
- i: {
73
- alias: 'ignore',
74
- describe: 'provide a glob pattern of files to ignore',
75
- type: 'string',
76
- },
77
- j: {
78
- alias: 'json',
79
- describe: 'output as json file',
80
- type: 'boolean',
81
- },
82
- o: {
83
- alias: 'output',
84
- describe: 'specify the directory in which the files are output',
85
- type: 'string',
86
- },
87
- });
88
- },
89
- handler: sassdoc,
90
- };