-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): Lazy install storybook #8454
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f78df36
initial package skeleton implemented
Josh-Walker-GM 2342536
Remove package versioning for just now
Josh-Walker-GM 5653ff7
move dependencies around
Josh-Walker-GM fe3266d
Update package installing.
Josh-Walker-GM 0abb0b3
Merge remote-tracking branch 'origin/main' into jgmw-cli/storybook-pa…
Josh-Walker-GM ba427f2
Remove bin handling from esbuild
Josh-Walker-GM 6f746b4
Update toml defaults
Josh-Walker-GM 310a6c5
Add aliases to the storybook command
Josh-Walker-GM fb32001
Add default `command-cache.json` to crwa templates
Josh-Walker-GM 2af9c8f
Apply suggestions from code review
jtoar a3a80e5
Merge branch 'main' into jgmw-cli/storybook-package
jtoar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice makes sense