Skip to content

Commit

Permalink
Merge branch 'master' into table-toolbar-search-accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 7, 2020
2 parents 6b9d293 + 56282c6 commit bcbc6f8
Show file tree
Hide file tree
Showing 106 changed files with 8,455 additions and 8,385 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,15 @@
"contributions": [
"code"
]
},
{
"login": "munkurious",
"name": "Boston Cartwright",
"avatar_url": "https://avatars0.githubusercontent.com/u/2187109?v=4",
"profile": "https://github.com/munkurious",
"contributions": [
"code"
]
}
],
"commitConvention": "none"
Expand Down
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ packages/components/node_modules

# React
**/storybook-static/**

# Templates
packages/cli/src/component/templates/**
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
ci-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Install dependencies
run: yarn install --offline
- name: Build project
run: yarn build
- name: Run Continuous Integration checks
run: |
yarn ci-check
yarn lerna run ci-check
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ packages/components/docs/js

# Generated files
**/generated/**

# Templates
**/*.template.*
Binary file added .yarn/offline-mirror/ansi-colors-4.1.1.tgz
Binary file not shown.
Binary file added .yarn/offline-mirror/enquirer-2.3.6.tgz
Binary file not shown.
Binary file removed .yarn/offline-mirror/is-reference-1.1.4.tgz
Binary file not shown.
Binary file not shown.
Binary file not shown.
127 changes: 64 additions & 63 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/browserslist-config-carbon/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "browserslist-config-carbon",
"description": "Browserslist config for the Carbon Design System",
"version": "10.6.0-rc.0",
"version": "10.6.0",
"license": "Apache-2.0",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion config/eslint-config-carbon/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eslint-config-carbon",
"description": "ESLint configuration for Carbon",
"version": "2.2.0-rc.0",
"version": "2.2.0",
"license": "Apache-2.0",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion config/prettier-config-carbon/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "prettier-config-carbon",
"description": "Prettier config for the Carbon Design System",
"version": "0.5.0-rc.0",
"version": "0.5.0",
"license": "Apache-2.0",
"main": "index.js",
"repository": {
Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions config/storybook-preset-carbon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright IBM Corp. 2016, 2018
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = {
addons: [
'@storybook/addon-knobs',
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-docs',

// Phase 1: port over add-ons from packages/react/.storybook
// Phase 2: port over webpack config for Sass
// Phase 3: port over custom panels/add-ons
],

// We get the current config and we return the new webpack config
webpack(config) {
// Configure sass
// sass-loader
// css-loader, style-loader, postcss-loader, ...

return config;
},
};
27 changes: 27 additions & 0 deletions config/storybook-preset-carbon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "storybook-preset-carbon",
"private": true,
"version": "0.0.0",
"license": "Apache-2.0",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/carbon-design-system/carbon.git",
"directory": "config/storybook-preset-carbon"
},
"bugs": "https://github.com/carbon-design-system/carbon/issues",
"keywords": [
"ibm",
"carbon",
"carbon-design-system",
"components",
"react"
],
"dependencies": {
"@storybook/addon-knobs": "^5.3.19",
"@storybook/addon-storysource": "^5.3.19",
"@storybook/addon-actions": "^5.3.19",
"@storybook/addon-docs": "^5.3.19",
"@storybook/addon-links": "^5.3.19"
}
}
2 changes: 1 addition & 1 deletion config/stylelint-config-carbon/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stylelint-config-carbon",
"description": "Stylelint configuration for Carbon",
"version": "1.3.0-rc.0",
"version": "1.3.0",
"license": "Apache-2.0",
"main": "index.js",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/bundler/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@carbon/bundler",
"description": "Bundler used for libraries in the Carbon Design System",
"version": "10.10.0-rc.0",
"version": "10.10.0",
"license": "Apache-2.0",
"bin": {
"bundler": "./bin/bundler.js"
Expand All @@ -27,7 +27,7 @@
"dependencies": {
"@babel/core": "^7.10.0",
"@babel/preset-env": "^7.10.0",
"@carbon/cli-reporter": "^10.4.0-rc.0",
"@carbon/cli-reporter": "^10.4.0",
"@commitlint/parse": "^8.3.4",
"autoprefixer": "^9.7.4",
"babel-plugin-macros": "^2.4.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-reporter/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@carbon/cli-reporter",
"description": "Reporter for CLI-based tools in the Carbon Design System",
"version": "10.4.0-rc.0",
"version": "10.4.0",
"license": "Apache-2.0",
"main": "index.js",
"repository": {
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@carbon/cli",
"description": "Task automation for working with the Carbon Design System",
"version": "10.16.0-rc.0",
"version": "10.16.0",
"license": "Apache-2.0",
"bin": {
"carbon-cli": "./bin/carbon-cli.js"
Expand All @@ -23,18 +23,20 @@
"access": "public"
},
"dependencies": {
"@carbon/cli-reporter": "^10.4.0-rc.0",
"@carbon/cli-reporter": "^10.4.0",
"@octokit/plugin-retry": "^2.2.0",
"@octokit/plugin-throttling": "^2.6.0",
"@octokit/rest": "^16.28.1",
"chalk": "^2.4.2",
"child-process-promise": "^2.2.1",
"clipboardy": "^2.1.0",
"enquirer": "^2.3.6",
"fast-glob": "^3.2.2",
"fs-extra": "^8.0.1",
"inquirer": "^6.4.1",
"lodash.template": "^4.5.0",
"prettier": "^2.1.0",
"prettier-config-carbon": "^0.5.0-rc.0",
"prettier-config-carbon": "^0.5.0",
"progress-estimator": "^0.2.2",
"remark": "^10.0.1",
"yargs": "^15.1.0"
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ async function main({ argv }) {
console.error(error.stderr);
process.exit(1);
}
throw error;
console.error(error);
process.exit(1);
return;
}
console.log(message);
console.log(yargs.help());
Expand Down
130 changes: 130 additions & 0 deletions packages/cli/src/commands/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/**
* Copyright IBM Corp. 2019, 2019
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

const { paramCase } = require('change-case');
const fs = require('fs-extra');
const { prompt } = require('enquirer');
const path = require('path');
const { loadTemplates } = require('../component');
const { createLogger } = require('../logger');

const logger = createLogger('component');

function clearConsole() {
process.stdout.write(
process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'
);
}

async function component() {
const templates = await loadTemplates();
const questions = [
{
type: 'input',
name: 'name',
message: 'What is the name of this component?',
validate(value) {
if (value === '') {
return 'A name is required for the component';
}
return true;
},
},
{
type: 'input',
name: 'directory',
message: 'Specify the path for this component',
initial: '.',
},
{
type: 'multiselect',
name: 'options',
message: 'What else should we scaffold out for you?',
initial: ['tests', 'stories'],
choices: [
{
name: 'tests',
value: true,
},
{
name: 'stories',
value: true,
},
],
result(names) {
return this.map(names);
},
},
];

clearConsole();
const answers = await prompt(questions);

logger.start('Generating component...');

const directory = path.resolve(
process.cwd(),
answers.directory,
answers.name
);

logger.info(`Writing component directory to ${directory}`);

if (await fs.exists(directory)) {
throw new Error(`A directory already exists at ${directory}`);
}

logger.info('Scaffolding out default files...');

await fs.ensureDir(directory);
await fs.writeFile(
path.join(directory, 'index.js'),
templates.index.compile({ name: answers.name })
);
await fs.writeFile(
path.join(directory, `${answers.name}.js`),
templates.component.compile({ name: answers.name })
);

if (answers.options.tests) {
logger.start('Scaffolding out test files...');
await fs.ensureDir(path.join(directory, '__tests__'));
await fs.writeFile(
path.join(directory, '__tests__', `${answers.name}-test.js`),
templates.test.compile({ name: answers.name })
);
logger.stop();
}

if (answers.options.stories) {
logger.start('Scaffolding out story files...');
await fs.writeFile(
path.join(directory, `${answers.name}-story.js`),
templates.story.compile({
name: answers.name,
})
);
await fs.writeFile(
path.join(directory, `${answers.name}.mdx`),
templates.mdx.compile({
name: answers.name,
url: paramCase(answers.name),
})
);
logger.stop();
}

logger.stop();
}

module.exports = {
command: 'component',
desc: '[EXPERIMENTAL] Scaffold a component in React',
handler: component,
};
47 changes: 47 additions & 0 deletions packages/cli/src/component/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright IBM Corp. 2019, 2019
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

const fs = require('fs-extra');
const path = require('path');
const template = require('lodash.template');

const TEMPLATES_DIR = path.join(__dirname, 'templates');
const blocklist = new Set(['.DS_Store']);

async function loadTemplates() {
const files = await fs.readdir(TEMPLATES_DIR).then((names) => {
return names
.filter((name) => {
return !blocklist.has(name);
})
.map((name) => {
const extension = path.extname(name);
return {
name: path.basename(name, `.template${extension}`),
filepath: path.join(TEMPLATES_DIR, name),
};
});
});

const templates = {};

for (const { name, filepath } of files) {
const contents = await fs.readFile(filepath, 'utf8');
const compile = template(contents);
templates[name] = {
compile,
};
}

return templates;
}

module.exports = {
loadTemplates,
};
Loading

0 comments on commit bcbc6f8

Please sign in to comment.