@carbon/cli 10.29.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/LICENSE +201 -0
- package/README.md +57 -0
- package/bin/carbon-cli.js +46 -0
- package/docker-compose.yml +13 -0
- package/package.json +56 -0
- package/src/changelog.js +217 -0
- package/src/cli.js +39 -0
- package/src/commands/bundle/bundlers.js +14 -0
- package/src/commands/bundle/javascript.js +142 -0
- package/src/commands/bundle.js +67 -0
- package/src/commands/changelog.js +70 -0
- package/src/commands/check.js +71 -0
- package/src/commands/ci-check.js +51 -0
- package/src/commands/component.js +130 -0
- package/src/commands/contribute/setup.js +232 -0
- package/src/commands/contribute/tools/getGitHubClient.js +73 -0
- package/src/commands/contribute.js +16 -0
- package/src/commands/inline.js +170 -0
- package/src/commands/publish.js +274 -0
- package/src/commands/release.js +302 -0
- package/src/commands/sassdoc/tools.js +405 -0
- package/src/commands/sassdoc.js +90 -0
- package/src/commands/sync/npm.js +43 -0
- package/src/commands/sync/package.js +122 -0
- package/src/commands/sync/readme.js +68 -0
- package/src/commands/sync/remark/remark-monorepo.js +425 -0
- package/src/commands/sync.js +39 -0
- package/src/compile.js +26 -0
- package/src/component/index.js +47 -0
- package/src/component/templates/component.template.js +19 -0
- package/src/component/templates/index.template.js +9 -0
- package/src/component/templates/mdx.template.mdx +37 -0
- package/src/component/templates/story.template.js +22 -0
- package/src/component/templates/test.template.js +35 -0
- package/src/git.js +38 -0
- package/src/logger.js +95 -0
- package/src/workspace.js +60 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2020
|
|
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
|
+
import { cleanup, render, screen } from '@testing-library/react';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { <%= name %> } from '../';
|
|
11
|
+
|
|
12
|
+
describe('<%= name %>', () => {
|
|
13
|
+
afterEach(cleanup);
|
|
14
|
+
|
|
15
|
+
it('should work', () => {
|
|
16
|
+
render(<<%= name %>>test</<%= name %>>);
|
|
17
|
+
// TODO
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('automated accessibility testing', () => {
|
|
21
|
+
it('should have no axe violations', async () => {
|
|
22
|
+
render(<<%= name %>>test</<%= name %>>);
|
|
23
|
+
await expect(screen.getByText('test')).toHaveNoAxeViolations();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should have no accessibility checker violations', async () => {
|
|
27
|
+
render(<<%= name %>>test</<%= name %>>);
|
|
28
|
+
await expect(screen.getByText('test')).toHaveNoACViolations('<%= name %>');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('Component API', () => {
|
|
33
|
+
// TODO
|
|
34
|
+
});
|
|
35
|
+
});
|
package/src/git.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2019, 2019
|
|
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 execa = require('execa');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* For certain release types, we want to be certain that our base branch is
|
|
14
|
+
* up-to-date with the upstream remote. This helper will first check that the
|
|
15
|
+
* upstream remote exists, and create it if it does not, and then will pull the
|
|
16
|
+
* latest changes into the local project.
|
|
17
|
+
*
|
|
18
|
+
* @returns {void}
|
|
19
|
+
*/
|
|
20
|
+
async function fetchLatestFromUpstream() {
|
|
21
|
+
try {
|
|
22
|
+
// This command will fail is no upstream is present, with `catch` we can
|
|
23
|
+
// create the appropriate remote before running the next commands
|
|
24
|
+
await execa('git', ['remote', 'get-url', 'upstream']);
|
|
25
|
+
} catch {
|
|
26
|
+
await execa('git', [
|
|
27
|
+
'remote',
|
|
28
|
+
'add',
|
|
29
|
+
'upstream',
|
|
30
|
+
'git@github.com:carbon-design-system/carbon.git',
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
await execa('git', ['fetch', 'upstream', 'main', '--tags']);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
fetchLatestFromUpstream,
|
|
38
|
+
};
|
package/src/logger.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2019, 2019
|
|
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 chalk = require('chalk');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Create a logger to be used in a handler. This is typically just for
|
|
14
|
+
* formatting the output, adding a prefix, and connecting the output with
|
|
15
|
+
* box-drawing ASCII characters.
|
|
16
|
+
* @returns {object}
|
|
17
|
+
*/
|
|
18
|
+
function createLogger(command) {
|
|
19
|
+
const timers = [];
|
|
20
|
+
let indentLevel = 0;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Display the given message with a box character. This also includes
|
|
24
|
+
* formatting for the logger prefix and box character itself.
|
|
25
|
+
* @param {string} boxCharacter
|
|
26
|
+
* @param {string?} message
|
|
27
|
+
* @returns {void}
|
|
28
|
+
*/
|
|
29
|
+
function log(boxCharacter, message = '') {
|
|
30
|
+
console.log(chalk`{yellow ${command} ▐} {gray ${boxCharacter}} ${message}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getLinePrefix() {
|
|
34
|
+
let prefix = '';
|
|
35
|
+
for (let i = 0; i < indentLevel; i++) {
|
|
36
|
+
prefix += '┃ ';
|
|
37
|
+
}
|
|
38
|
+
return prefix;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
info(message) {
|
|
43
|
+
indentLevel -= 1;
|
|
44
|
+
const prefix = getLinePrefix();
|
|
45
|
+
indentLevel += 1;
|
|
46
|
+
|
|
47
|
+
log(prefix + '┣', chalk.gray(message));
|
|
48
|
+
},
|
|
49
|
+
start(message) {
|
|
50
|
+
const start = Date.now();
|
|
51
|
+
timers.push(start);
|
|
52
|
+
|
|
53
|
+
const prefix = getLinePrefix();
|
|
54
|
+
log(prefix + '┏', message);
|
|
55
|
+
|
|
56
|
+
indentLevel += 1;
|
|
57
|
+
},
|
|
58
|
+
stop(message) {
|
|
59
|
+
indentLevel -= 1;
|
|
60
|
+
|
|
61
|
+
const duration = ((Date.now() - timers.pop()) / 1000).toFixed(2);
|
|
62
|
+
const prefix = getLinePrefix();
|
|
63
|
+
|
|
64
|
+
if (message) {
|
|
65
|
+
log(prefix + '┗', message);
|
|
66
|
+
} else {
|
|
67
|
+
log(prefix + '┗', chalk`{gray Done in {italic ${duration}s}}`);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
newline() {
|
|
71
|
+
const prefix = getLinePrefix();
|
|
72
|
+
log(prefix + '┃');
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Display the banner in the console, typically at the beginning of a handler
|
|
79
|
+
* @returns {void}
|
|
80
|
+
*/
|
|
81
|
+
function displayBanner() {
|
|
82
|
+
console.log(`
|
|
83
|
+
_
|
|
84
|
+
| |
|
|
85
|
+
___ __ _ _ __| |__ ___ _ __
|
|
86
|
+
/ __/ _\` | '__| '_ \\ / _ \\| '_ \\
|
|
87
|
+
| (_| (_| | | | |_) | (_) | | | |
|
|
88
|
+
\\___\\__,_|_| |_.__/ \\___/|_| |_|
|
|
89
|
+
`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
createLogger,
|
|
94
|
+
displayBanner,
|
|
95
|
+
};
|
package/src/workspace.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2019, 2019
|
|
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 execa = require('execa');
|
|
11
|
+
const fs = require('fs-extra');
|
|
12
|
+
const glob = require('fast-glob');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const packageJson = require('../../../package.json');
|
|
15
|
+
|
|
16
|
+
const WORKSPACE_ROOT = path.resolve(__dirname, '../../../');
|
|
17
|
+
const packagePaths = glob
|
|
18
|
+
.sync(packageJson.workspaces.map((pattern) => `${pattern}/package.json`))
|
|
19
|
+
.map((match) => {
|
|
20
|
+
const packageJsonPath = path.join(WORKSPACE_ROOT, match);
|
|
21
|
+
return {
|
|
22
|
+
packageJsonPath,
|
|
23
|
+
packageJson: fs.readJsonSync(packageJsonPath),
|
|
24
|
+
packagePath: path.dirname(packageJsonPath),
|
|
25
|
+
packageFolder: path.relative(
|
|
26
|
+
WORKSPACE_ROOT,
|
|
27
|
+
path.dirname(packageJsonPath)
|
|
28
|
+
),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const env = {
|
|
33
|
+
root: {
|
|
34
|
+
directory: WORKSPACE_ROOT,
|
|
35
|
+
packageJson,
|
|
36
|
+
},
|
|
37
|
+
packagePaths,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function workspace(fn) {
|
|
41
|
+
return (...args) => fn(...args, env);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Lists the packages for the current project using the `lerna list` command
|
|
46
|
+
* @returns {Array<PackageInfo>}
|
|
47
|
+
*/
|
|
48
|
+
async function getPackages() {
|
|
49
|
+
const { stdout: lernaListOutput } = await execa('yarn', [
|
|
50
|
+
'lerna',
|
|
51
|
+
'list',
|
|
52
|
+
'--json',
|
|
53
|
+
]);
|
|
54
|
+
return JSON.parse(lernaListOutput).filter((pkg) => !pkg.private);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
workspace,
|
|
59
|
+
getPackages,
|
|
60
|
+
};
|