Skip to content

Commit

Permalink
chore: merge ui-token-scripts into ui-scripts
Browse files Browse the repository at this point in the history
Also add documentation to ui-scripts commands and simplify it a bit.
  • Loading branch information
matyasf committed Sep 14, 2023
1 parent fc77c9f commit b201fd6
Show file tree
Hide file tree
Showing 30 changed files with 143 additions and 988 deletions.
15 changes: 0 additions & 15 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
NPM_TOKEN=
NPM_USERNAME=
NPM_EMAIL=
GIT_EMAIL=""
GIT_USERNAME=
GIT_REMOTE_URL=gerrit:instructure-ui
GIT_REMOTE_NAME=origin
JIRA_CONSUMER_KEY=
JIRA_TOKEN=
JIRA_SECRET=
JIRA_PEM_PATH=/Users/your_user_name/.ssh/jira.pem
SLACK_USERNAME=instui
SLACK_WEBHOOK=
SSH_KEY_PATH=
SSH_USERNAME=
CHROMATIC_APP_CODE=
GERRIT_HOST=
GERRIT_PORT=
42 changes: 6 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"build": "lerna run build --stream",
"build:watch": "lerna run build:watch --stream",
"build:docs": "lerna run bundle --stream --scope docs-app",
"build:tokens": "ui-token-scripts generate-all-tokens",
"build:tokens": "ui-scripts generate-all-tokens",
"build:types": "tsc -b tsconfig.references.json",
"build:ts": "lerna run prepare-build --stream --scope @instructure/ui-icons && npm run build:types --verbose",
"clean": "node scripts/clean.js",
Expand Down Expand Up @@ -69,7 +69,6 @@
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@instructure/ui-scripts": "8.41.1",
"@instructure/ui-token-scripts": "8.41.1",
"@testing-library/dom": "^9.3.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^14.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

// note: This cannot be converted to ESM until ESLint v9 is released:
// https://github.com/eslint/eslint/issues/15453#issuecomment-1002015088
const path = require('path')
const { readPackage } = require('@instructure/pkg-utils')

Expand Down
1 change: 0 additions & 1 deletion packages/instui-config/package-lists/v9/package-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
"@instructure/ui-themes",
"@instructure/ui-time-select",
"@instructure/ui-toggle-details",
"@instructure/ui-token-scripts",
"@instructure/ui-tooltip",
"@instructure/ui-top-nav-bar",
"@instructure/ui-tray",
Expand Down
139 changes: 52 additions & 87 deletions packages/ui-scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,73 @@ category: packages
[![MIT License][license-badge]][license] 
[![Code of Conduct][coc-badge]][coc]

A CLI tool for UI component libraries made by Instructure Inc.
A CLI tool for InstUI build and publish tools made by Instructure Inc.

### Installation
### Scripts

For more documentation on available options and parameters for individual commands run:

```sh
npm install @instructure/ui-scripts
ui-scripts <command> --help
```

### Scripts

#### `build`
#### build

To build (babel transpile) a package to be consumed as a library:

`npm run ui-scripts build`
`npm run ui-scripts build --modules cjs` writes commonjs modules to the lib/ directory.

`npm run ui-scripts build --modules es` writes es modules to the es/ directory.

`npm run ui-scripts build --modules es,cjs` writes es modules to both directories.

If not specified, `modules` defaults to `es`.

To build (webpack) a package to be consumed as an application:

`npm run ui-scripts bundle`

#### `clean`
#### bump version

To update all package versions
(defaults to determining the version automatically using commit messages):

`npm run ui-scripts bump [version|major|minor|patch]`

#### clean

To clean out built/generated files from a package:

`npm run ui-scripts clean`

#### `modules`
#### deprecate

`npm run ui-scripts build --modules cjs` writes commonjs modules to the lib/ directory.
Deprecates ALL of a certain version of instUI npm packages by running `npm deprecate`.
`versionToDeprecate` defaults to the current version.

`npm run ui-scripts build --modules es` writes es modules to the es/ directory.
`npm run ui-scripts deprecate --versionToDeprecate 5.11.0 --fixVersion 5.11.1`

`npm run ui-scripts build --modules es,cjs` writes es modules to both directories.
#### examples (Storybook)

If not specified, `modules` defaults to `es`.
To build component examples and start up a dev server with hot reloading:

#### `test`
`npm run ui-scripts examples --watch -p 8080`

To run tests for a package:
To build component examples for deploying:

`npm run ui-scripts test`
`npm run ui-scripts examples`

#### generating design tokens

`npm run generate-tokens <options>`

Generate cross-platform design tokens for the given theme.

#### `lint`
`npm run generate-all-tokens`

Generate cross-platform design tokens for all themes in the repo.

#### lint

To lint (eslint/stylelint) all files:

Expand All @@ -64,49 +88,19 @@ To fix lint issues:

`npm run ui-scripts lint --fix`

#### `install-react`

To install a specific version of React and ReactDOM without updating `package.json`
(defaults to the versions specified in the resolutions field):

`npm run ui-scripts install-react [version]`

#### `bump`

To update all package versions
(defaults to determining the version automatically using commit messages):

`npm run ui-scripts bump [version|major|minor|patch]`

#### `publish`
#### publish to npm

To publish all packages (defaults to current version):

`npm run ui-scripts publish [version]`

#### `deploy-docs`

To run the deploy of the documentation (to Github pages):

`npm run ui-scripts deploy-docs`

#### `examples`

To build component examples and start up a dev server with hot reloading:

`npm run ui-scripts examples --watch -p 8080`

To build component examples for deploying:

`npm run ui-scripts examples`

#### `server`
#### server

To start up a server to test production builds of examples or docs:

`npm run ui-scripts server -p 8080`

#### `tag`
#### npm tag

To add an NPM dist-tag for all packages:

Expand All @@ -116,55 +110,26 @@ To remove an NPM dist-tag for all packages:

`npm run ui-scripts tag rm 5.11.0 latest`

#### `deprecate`
#### running tests

To deprecate all packages (optional arguments: version, fix version):
To run all tests:

`npm run ui-scripts deprecate 5.11.0 5.11.1`
`npm run ui-scripts test`

### Configuration
To run tests for a package:

If you'd like to use the publish, deploy, and release scripts, you'll need to configure your project as follows:
`npm run ui-scripts test -- --scope @instructure/ui-avatar`

#### Project level

Add the config to your project level `package.json` file:

```json
"config": {
"ui-scripts": {
"slack_emoji": ":instui:",
"slack_channel": "#instui",
"jira_host": "instructure.atlassian.net",
"jira_project_id": "17900",
"jira_project_key": "INSTUI",
"npm_scope": "@instructure:registry=https://registry.npmjs.org/",
"gh_pages_branch": "gh-pages",
"gh_pages_dir": "packages/__docs__/__build__",
"gh_pages_cname": "instructure.design",
"changelog_url": "https://instructure.design/#CHANGELOG"
}
}
```
### Configuration

#### Environment variables
If you'd like to use the publish, deploy, and release scripts, you'll need to configure your project as follows:

Add a `.env` file to your project root:
Add a `.env` file to your project root or define these env vars for your shell:

```sh
NPM_TOKEN=
NPM_USERNAME=
NPM_EMAIL=
GIT_EMAIL=""
GIT_USERNAME=
GIT_REMOTE_URL=gerrit:instructure-ui
GIT_REMOTE_NAME=origin
JIRA_CONSUMER_KEY=
JIRA_TOKEN=
JIRA_SECRET=
JIRA_PEM_PATH=/Users/your_user_name/.ssh/jira.pem
SLACK_USERNAME=instui
SLACK_WEBHOOK=
```

[npm]: https://img.shields.io/npm/v/@instructure/ui-scripts.svg
Expand Down
14 changes: 10 additions & 4 deletions packages/ui-scripts/lib/build/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ const specifyCJSFormat = path.resolve(__dirname, 'specify-commonjs-format.js')

export default {
command: 'build',
desc: '',
desc: 'Build the packages with Babel.js',
builder: (yargs) => {
yargs.option('copy-files', { boolean: true, desc: '' })
yargs.option('watch', { boolean: true, desc: '' })
yargs.option('copy-files', {
boolean: true,
desc: 'Copy files that will not be compiled'
})
yargs.option('watch', {
boolean: true,
desc: 'Run constantly and recompile on changes'
})
yargs.option('modules', {
string: true,
desc: '',
desc: 'What kind of modules to build. "es": build into the /es folder using ESM; "cjs": build into the /lib folder using commonJS',
choices: ['es', 'cjs'],
default: 'es',
coerce: (value) => value.split(',')
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-scripts/lib/build/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import fs from 'fs'

export default {
command: 'clean',
desc: '',
desc: 'Delete generated files and build outputs',
handler: async () => {
const dirs = [
'__build__',
Expand Down
Loading

0 comments on commit b201fd6

Please sign in to comment.