-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): Lazy install storybook (#8454)
* initial package skeleton implemented * Remove package versioning for just now * move dependencies around * Update package installing. Packages no longer require a version and will default to the same version as the redwood CLI if no version is specified. * Remove bin handling from esbuild * Update toml defaults * Add aliases to the storybook command * Add default `command-cache.json` to crwa templates * Apply suggestions from code review
- Loading branch information
1 parent
3d8c540
commit 8fb0f86
Showing
21 changed files
with
1,499 additions
and
1,166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# CLI Packages - Storybook | ||
|
||
**WIP**: This package is the first example of extracting a command from `@redwoodjs/cli` into it's own CLI plugin package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import fs from 'node:fs' | ||
|
||
import * as esbuild from 'esbuild' | ||
import fg from 'fast-glob' | ||
|
||
// Get source files | ||
const sourceFiles = fg.sync(['./src/**/*.ts']) | ||
|
||
// Build general source files | ||
const result = await esbuild.build({ | ||
entryPoints: sourceFiles, | ||
format: 'cjs', | ||
platform: 'node', | ||
target: ['node18'], | ||
outdir: 'dist', | ||
logLevel: 'info', | ||
|
||
// For visualizing the bundle. | ||
// See https://esbuild.github.io/api/#metafile and https://esbuild.github.io/analyze/. | ||
metafile: true, | ||
}) | ||
|
||
fs.writeFileSync('meta.json', JSON.stringify(result.metafile)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "@redwoodjs/cli-storybook", | ||
"version": "5.0.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/redwoodjs/redwood.git", | ||
"directory": "packages/cli-packages/storybook" | ||
}, | ||
"license": "MIT", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "yarn node ./build.mjs && yarn build:types", | ||
"build:types": "tsc --build --verbose", | ||
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"", | ||
"prepublishOnly": "NODE_ENV=production yarn build" | ||
}, | ||
"jest": { | ||
"testPathIgnorePatterns": [ | ||
"/dist/" | ||
] | ||
}, | ||
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1", | ||
"dependencies": { | ||
"@redwoodjs/project-config": "5.0.0", | ||
"@redwoodjs/telemetry": "5.0.0", | ||
"@storybook/addon-a11y": "7.0.18", | ||
"@storybook/addon-docs": "7.0.18", | ||
"@storybook/addon-essentials": "7.0.18", | ||
"@storybook/react-webpack5": "7.0.18", | ||
"chalk": "4.1.2", | ||
"execa": "5.1.1", | ||
"lodash.memoize": "4.1.2", | ||
"storybook": "7.0.18", | ||
"terminal-link": "2.1.1", | ||
"yargs": "17.7.2" | ||
}, | ||
"devDependencies": { | ||
"esbuild": "0.17.19", | ||
"fast-glob": "3.2.12", | ||
"jest": "29.5.0", | ||
"typescript": "5.1.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { | ||
command, | ||
aliases, | ||
description, | ||
builder, | ||
handler, | ||
} from './commands/storybook' | ||
|
||
export const commands = [ | ||
{ | ||
command, | ||
aliases, | ||
description, | ||
builder, | ||
handler, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import chalk from 'chalk' | ||
|
||
/** | ||
* To keep a consistent color/style palette between cli packages, such as | ||
* \@redwood/cli and \@redwood/create-redwood-app, please keep them compatible | ||
* with one and another. We'll might split up and refactor these into a | ||
* separate package when there is a strong motivation behind it. | ||
* | ||
* Current files: | ||
* | ||
* - packages/cli/src/lib/colors.js (this file) | ||
* - packages/create-redwood-app/src/create-redwood-app.js | ||
*/ | ||
export default { | ||
error: chalk.bold.red, | ||
warning: chalk.keyword('orange'), | ||
green: chalk.green, | ||
info: chalk.grey, | ||
bold: chalk.bold, | ||
underline: chalk.underline, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { memoize } from 'lodash' | ||
|
||
import { getPaths as getRedwoodPaths } from '@redwoodjs/project-config' | ||
|
||
import c from './colors' | ||
|
||
/** | ||
* This wraps the core version of getPaths into something that catches the exception | ||
* and displays a helpful error message. | ||
*/ | ||
export const _getPaths = () => { | ||
try { | ||
return getRedwoodPaths() | ||
} catch (e) { | ||
console.error(c.error((e as Error).message)) | ||
process.exit(1) | ||
} | ||
} | ||
export const getPaths = memoize(_getPaths) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface StorybookYargsOptions { | ||
open: boolean | ||
build: boolean | ||
ci: boolean | ||
port: number | ||
buildDirectory: string | ||
smokeTest: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../../tsconfig.compilerOption.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"rootDir": "src", | ||
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo", | ||
"outDir": "dist" | ||
}, | ||
"include": ["src"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.