Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
steps:
- *attach_workspace
- run: yarn build:demo
- run: utils/scripts/deploy.js
- run: utils/scripts/deploy.mjs

publish:
<<: *executor
Expand Down
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"react/no-set-state": "error"
},
"overrides": [
{
"files": ["*.mjs"],
"rules": {
"node/no-unsupported-features/node-builtins": ["error", { "version": ">=18.0.0" }]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["@zendeskgarden/eslint-config/plugins/typescript", "prettier"],
Expand Down
25 changes: 10 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,28 @@
"build": "lerna run build --stream",
"build:analyze": "ANALYZE_BUNDLE=true yarn build:single",
"build:demo": "storybook build -o ./demo",
"build:single": "utils/scripts/scoped-npm-command.js --script build",
"format": "prettier-package-json --write && yarn format:package_json --write && yarn format:js --write && yarn format:md --write",
"format:all": "prettier-package-json --list-different && yarn format:package_json --list-different && yarn format:js --check && yarn format:md --check",
"format:js": "prettier --loglevel warn '{packages,utils}/**/*.{js,ts,tsx}' '!packages/.template' '!packages/**/dist/**'",
"format:js": "prettier --loglevel warn '{packages,utils}/**/*.{js,mjs,ts,tsx}' '!packages/.template' '!packages/**/dist/**'",
"format:md": "prettier --loglevel warn 'packages/**/*.{md,mdx}'",
"format:package_json": "lerna exec -- prettier-package-json",
"postinstall": "husky install && lerna bootstrap",
"lint": "yarn lint:css && yarn lint:js && yarn lint:md",
"lint:css": "stylelint '{packages,utils}/**/*.{js,ts,tsx}'",
"lint:js": "eslint .storybook/ packages/ utils/ --ext js,ts,tsx --max-warnings 0",
"lint:js": "eslint .storybook/ packages/ utils/ --ext js,mjs,ts,tsx --max-warnings 0",
"lint:md": "markdownlint README.md packages/*/README.md packages/*/demo/**/*.mdx",
"new": "utils/scripts/new.js",
"new": "utils/scripts/new.mjs",
"prepare": "yarn build",
"start": "storybook dev --no-version-updates -p 6006",
"tag": "utils/scripts/tag.js",
"tag": "utils/scripts/tag.mjs",
"test": "jest --config=utils/test/jest.config.js",
"test:ci": "yarn lint && yarn format:all && yarn tsc && yarn test --coverage",
"test:watch": "yarn test --watch",
"preversion": "yarn test:ci",
"version": "yarn build && git add -A"
},
"resolutions": {
"string-width": "4.2.3",
"strip-ansi": "6.0.1"
"string-width": "4.2.3"
},
"devDependencies": {
"@babel/cli": "7.22.10",
Expand Down Expand Up @@ -67,7 +65,7 @@
"@typescript-eslint/parser": "6.3.0",
"@zendeskgarden/css-bedrock": "9.1.1",
"@zendeskgarden/eslint-config": "34.0.0",
"@zendeskgarden/scripts": "1.4.3",
"@zendeskgarden/scripts": "2.0.0",
"@zendeskgarden/stylelint-config": "20.0.0",
"@zendeskgarden/svg-icons": "6.33.0",
"acorn-jsx": "5.3.2",
Expand All @@ -76,8 +74,7 @@
"babel-plugin-module-resolver": "5.0.0",
"babel-plugin-react-remove-properties": "0.3.0",
"babel-plugin-styled-components": "2.1.4",
"chalk": "4.1.2",
"commander": "10.0.1",
"commander": "11.0.0",
"core-js": "3.32.0",
"coveralls": "3.1.1",
"envalid": "7.3.1",
Expand All @@ -90,12 +87,10 @@
"eslint-plugin-notice": "0.9.10",
"eslint-plugin-react": "7.33.1",
"eslint-plugin-react-hooks": "4.6.0",
"execa": "5.1.1",
"fuzzy": "0.1.3",
"execa": "7.2.0",
"husky": "8.0.3",
"identity-obj-proxy": "3.0.0",
"inquirer": "8.2.6",
"inquirer-autocomplete-prompt": "2.0.0",
"inquirer": "9.2.10",
"jest": "29.6.2",
"jest-environment-jsdom": "29.6.2",
"jest-styled-components": "7.1.1",
Expand All @@ -104,7 +99,7 @@
"markdownlint-cli": "0.35.0",
"micromatch": "4.0.5",
"mockdate": "3.0.5",
"ora": "5.4.1",
"ora": "7.0.1",
"pluralize": "8.0.0",
"postcss-styled-syntax": "0.4.0",
"prettier": "2.8.8",
Expand Down
35 changes: 23 additions & 12 deletions utils/scripts/deploy.js → utils/scripts/deploy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

const envalid = require('envalid');
const garden = require('@zendeskgarden/scripts');
const path = require('path');
import envalid from 'envalid';
import {
cmdDu,
githubBranch,
githubCommit,
githubDeploy,
githubPages,
githubRepository,
netlifyBandwidth,
netlifyDeploy
} from '@zendeskgarden/scripts';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';

envalid.cleanEnv(process.env, {
GITHUB_TOKEN: envalid.str(),
Expand All @@ -19,30 +29,31 @@ envalid.cleanEnv(process.env, {

(async () => {
try {
const branch = await garden.githubBranch();
const dir = path.resolve(__dirname, '..', '..', 'demo');
const branch = await githubBranch();
const currentDir = dirname(fileURLToPath(import.meta.url));
const dir = resolve(currentDir, '..', '..', 'demo');
let url;

if (branch === 'main') {
url = await garden.githubPages({ dir });
url = await githubPages({ dir });
} else {
const bandwidth = await garden.netlifyBandwidth();
const usage = await garden.cmdDu(dir);
const bandwidth = await netlifyBandwidth();
const usage = await cmdDu(dir);

if (bandwidth.available > usage) {
const repository = await garden.githubRepository();
const commit = await garden.githubCommit();
const repository = await githubRepository();
const commit = await githubCommit();
const message = `https://github.com/${repository.owner}/${repository.repo}/commit/${commit}`;
const command = async () => {
const result = await garden.netlifyDeploy({
const result = await netlifyDeploy({
dir,
message
});

return result;
};

url = await garden.githubDeploy({ command });
url = await githubDeploy({ command });
} else {
throw new Error(
`Insufficient Netlify bandwidth: ${bandwidth.available} bytes available, ${usage} bytes required.`
Expand Down
21 changes: 12 additions & 9 deletions utils/scripts/new.js → utils/scripts/new.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

const program = require('commander');
const execa = require('execa');
const garden = require('@zendeskgarden/scripts');
const ora = require('ora');
const pluralize = require('pluralize');
const resolve = require('path').resolve;
import { Command } from 'commander';
import { execa } from 'execa';
import { lernaNew } from '@zendeskgarden/scripts';
import ora from 'ora';
import pluralize from 'pluralize';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';

const program = new Command();
const info = (message, spinner) => spinner.info(message).start();

/**
Expand Down Expand Up @@ -44,9 +46,10 @@ const bootstrap = async (component, spinner) => {
* @returns The package destination directory path.
*/
const generate = async (component, spinner) => {
const src = resolve(__dirname, '..', '..', 'packages', '.template');
const currentDir = dirname(fileURLToPath(import.meta.url));
const src = resolve(currentDir, '..', '..', 'packages', '.template');
const dest = resolve(
__dirname,
currentDir,
'..',
'..',
'packages',
Expand All @@ -56,7 +59,7 @@ const generate = async (component, spinner) => {

info(`Generating package...`, spinner);

const result = await garden.lernaNew({ src, dest, tags, spinner });
const result = await lernaNew({ src, dest, tags, spinner });

return result.dest;
};
Expand Down
106 changes: 0 additions & 106 deletions utils/scripts/scoped-npm-command.js

This file was deleted.

36 changes: 21 additions & 15 deletions utils/scripts/tag.js → utils/scripts/tag.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

const program = require('commander');
const execa = require('execa');
const fs = require('fs');
const garden = require('@zendeskgarden/scripts');
const lernaConfig = require('../../lerna.json');
const ora = require('ora');
const inquirer = require('inquirer');
const resolve = require('path').resolve;
const temp = require('temp').track();
const util = require('util');

import { Command } from 'commander';
import { execa } from 'execa';
import fs from 'fs';
import { githubBranch, githubRelease, lernaChangelog } from '@zendeskgarden/scripts';
import ora from 'ora';
import inquirer from 'inquirer';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
import { track } from 'temp';
import util from 'util';
import { createRequire } from 'module';

const lernaConfig = createRequire(import.meta.url)('../../lerna.json');
const temp = track();

const program = new Command();
const info = (message, spinner) => spinner.info(message).start();

/**
Expand All @@ -36,7 +41,7 @@ const changelog = async (tag, spinner) => {
const write = util.promisify(fs.write);
const open = util.promisify(temp.open);
const { path, fd } = await open({ prefix: 'CHANGELOG', suffix: '.md' });
const markdown = await garden.lernaChangelog({ spinner });
const markdown = await lernaChangelog({ spinner });
const editor = await execa('git', ['var', 'GIT_EDITOR']);

await write(fd, markdown);
Expand All @@ -46,7 +51,8 @@ const changelog = async (tag, spinner) => {

const readFile = util.promisify(fs.readFile);
const INSERTION_SLUG = '<!-- insert-new-changelog-here -->';
const changelogPath = resolve(__dirname, '..', '..', 'CHANGELOG.md');
const currentDir = dirname(fileURLToPath(import.meta.url));
const changelogPath = resolve(currentDir, '..', '..', 'CHANGELOG.md');
const data = await readFile(changelogPath, 'utf8');

if (data.includes(INSERTION_SLUG)) {
Expand Down Expand Up @@ -92,7 +98,7 @@ const release = async (tag, markdown, spinner) => {
await execa('git', pushArgs.concat('HEAD^:main'));
await execa('git', pushArgs.concat('main'));

const url = await garden.githubRelease({ tag, body: markdown, spinner });
const url = await githubRelease({ tag, body: markdown, spinner });

spinner.succeed(
`Success.\n🎗 Approve the draft release – ${url} – upon notification of a successful ${tag} publish to NPM.`
Expand All @@ -119,7 +125,7 @@ const rollback = async (tag, spinner) => {
* @param {Ora} spinner Terminal spinner.
*/
const sync = async (main, spinner) => {
const branch = await garden.githubBranch(undefined /* path */, spinner);
const branch = await githubBranch(undefined /* path */, spinner);

if (branch === main) {
info('Syncing with remote...', spinner);
Expand Down
Loading