Skip to content

Commit

Permalink
chore: move to Yarn 2 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetanmaisse committed Feb 15, 2021
1 parent 174be07 commit 1b87b77
Show file tree
Hide file tree
Showing 24 changed files with 47,501 additions and 34,662 deletions.
26 changes: 13 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ jobs:
- restore_cache:
name: Restore Yarn cache
keys:
- build-yarn-cache-v4--{{ checksum "yarn.lock" }}
- build-yarn-2-cache-v1--{{ checksum "yarn.lock" }}
- run:
name: Install dependencies
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
command: yarn install --immutable
- run:
name: Bootstrap
command: yarn bootstrap --core
- save_cache:
name: Save Yarn cache
key: build-yarn-cache-v4--{{ checksum "yarn.lock" }}
key: build-yarn-2-cache-v1--{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- ~/.yarn/berry/cache
- persist_to_workspace:
root: .
paths:
Expand Down Expand Up @@ -195,10 +195,10 @@ jobs:
command: yarn wait-on http://localhost:6000
- run:
name: set registry
command: yarn config set registry http://localhost:6000/
command: yarn config set npmRegistryServer http://localhost:6000/
- run:
name: test local registry
command: yarn info @storybook/core
command: yarn npm info @storybook/core
- run:
name: Install Cypress binary
command: yarn cypress install
Expand Down Expand Up @@ -237,10 +237,10 @@ jobs:
command: yarn wait-on http://localhost:6000
- run:
name: Set registry
command: yarn config set registry http://localhost:6000/
command: yarn config set npmRegistryServer http://localhost:6000/
- run:
name: Test local registry
command: yarn info @storybook/core
command: yarn npm info @storybook/core
- run:
name: Install Cypress binary
command: yarn cypress install
Expand Down Expand Up @@ -269,10 +269,10 @@ jobs:
command: yarn wait-on http://localhost:6000
- run:
name: Set registry
command: yarn config set registry http://localhost:6000/
command: yarn config set npmRegistryServer http://localhost:6000/
- run:
name: Test local registry
command: yarn info @storybook/core
command: yarn npm info @storybook/core
- run:
name: Install Cypress binary
command: yarn cypress install
Expand Down Expand Up @@ -301,10 +301,10 @@ jobs:
command: yarn wait-on http://localhost:6000
- run:
name: set registry
command: yarn config set registry http://localhost:6000/
command: yarn config set npmRegistryServer http://localhost:6000/
- run:
name: test local registry
command: yarn info @storybook/core
command: yarn npm info @storybook/core
- run:
name: Install Cypress binary
command: yarn cypress install
Expand Down Expand Up @@ -414,7 +414,7 @@ jobs:
clone_options: '--depth 1 --verbose'
- run:
name: Install dependencies
command: yarn bootstrap --install
command: yarn install --immutable
- run:
name: Trigger build
command: ./scripts/build-frontpage.js
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ jobs:
uses: actions/cache@v2
with:
path: node_modules
key: build-v2-${{ hashFiles('**/yarn.lock') }}
key: yarn-2-cache-v1-${{ hashFiles('**/yarn.lock') }}
- name: install, bootstrap
run: |
yarn install --immutable
yarn bootstrap --core
- name: test
run: |
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ cypress/screenshots
examples/ember-cli/ember-output
.verdaccio-cache
tsconfig.tsbuildinfo

# Yarn 2 stuff
/.yarn/*
!/.yarn/releases
!/.yarn/plugins
!/.yarn/sdks
!/.yarn/versions
/.pnp.*
55 changes: 55 additions & 0 deletions .yarn/releases/yarn-berry.cjs

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
yarnPath: .yarn/releases/yarn-berry.cjs
nodeLinker: node-modules

enableGlobalCache: true
compressionLevel: 0

npmRegistryServer: "https://registry.yarnpkg.com"
unsafeHttpWhitelist:
- localhost

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const runCompodoc = (inputPath: string) => {
// FIXME: for now, this requires a tsconfig.json for each test case. Tried generating
// one dynamically in tmpDir, but compodoc doesn't handle absolute paths properly
// (and screwed around with relative paths as well, but couldn't get it working)
spawnSync('compodoc', ['-p', `${testDir}/tsconfig.json`, '-e', 'json', '-d', tmpDir], {
spawnSync('yarn', ['compodoc', '-p', `${testDir}/tsconfig.json`, '-e', 'json', '-d', tmpDir], {
stdio: 'inherit',
});
const output = fs.readFileSync(`${tmpDir}/documentation.json`, 'utf8');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const inputRegExp = /^input\..*$/;
const runWebComponentsAnalyzer = (inputPath: string) => {
const { name: tmpDir, removeCallback } = tmp.dirSync();
const customElementsFile = `${tmpDir}/custom-elements.json`;
spawnSync('wca', ['analyze', inputPath, '--outFile', customElementsFile], {
spawnSync('yarn', ['wca', 'analyze', inputPath, '--outFile', customElementsFile], {
stdio: 'inherit',
});
const output = fs.readFileSync(customElementsFile, 'utf8');
Expand Down
7 changes: 3 additions & 4 deletions examples/angular-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
"license": "MIT",
"scripts": {
"build": "ng build",
"prebuild-storybook": "yarn storybook:prebuild",
"build-storybook": "build-storybook -s src/assets",
"build-storybook": "yarn storybook-prebuild && build-storybook -s src/assets",
"docs:json": "compodoc -p ./tsconfig.json -e json -d .",
"e2e": "ng e2e",
"ng": "ng",
"start": "ng serve",
"storybook": "yarn storybook:prebuild && start-storybook -p 9008 -s src/assets",
"storybook:prebuild": "yarn test:generate-output && yarn docs:json",
"storybook": "yarn storybook-prebuild && start-storybook -p 9008 -s src/assets",
"storybook-prebuild": "yarn test:generate-output && yarn docs:json",
"test": "jest",
"test:coverage": "jest --coverage",
"test:generate-output": "jest --json --config=jest.addon-config.js --outputFile=addon-jest.testresults.json || true",
Expand Down
2 changes: 1 addition & 1 deletion examples/ember-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build": "ember build --output-path ember-output",
"prebuild-storybook": "yarn build && shx cp -r public/* ember-output",
"build-storybook": "build-storybook -s ember-output",
"build-storybook": "yarn prebuild-storybook && build-storybook -s ember-output",
"dev": "ember serve",
"storybook": "yarn build && start-storybook -p 9009 -s ember-output",
"storybook:dev": "yarn dev & start-storybook -p 9009 -s ember-output"
Expand Down
4 changes: 1 addition & 3 deletions lib/cli-sb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
"directory": "lib/cli"
},
"license": "MIT",
"bin": {
"sb": "./index.js"
},
"bin": "./index.js",
"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
Expand Down
13 changes: 10 additions & 3 deletions lib/cli/src/generators/baseGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NpmOptions } from '../NpmOptions';
import { StoryFormat, SupportedLanguage, SupportedFrameworks } from '../project_types';
import { getBabelDependencies, copyComponents } from '../helpers';
import { configure } from './configure';
import { JsPackageManager } from '../js-package-manager';
import { getPackageDetails, JsPackageManager } from '../js-package-manager';

export type GeneratorOptions = {
language: SupportedLanguage;
Expand Down Expand Up @@ -64,21 +64,28 @@ export async function baseGenerator(
const yarn2Dependencies =
packageManager.type === 'yarn2' ? ['@storybook/addon-docs', '@mdx-js/react'] : [];

const packageJson = packageManager.retrievePackageJson();
const installedDependencies = new Set(Object.keys(packageJson.dependencies));

const packages = [
`@storybook/${framework}`,
...addonPackages,
...extraPackages,
...extraAddons,
...yarn2Dependencies,
].filter(Boolean);
]
.filter(Boolean)
.filter(
(packageToInstall) => !installedDependencies.has(getPackageDetails(packageToInstall)[0])
);

const versionedPackages = await packageManager.getVersionedPackages(...packages);

configure(framework, [...addons, ...extraAddons]);
if (addComponents) {
copyComponents(framework, language);
}

const packageJson = packageManager.retrievePackageJson();
const babelDependencies = addBabel ? await getBabelDependencies(packageManager, packageJson) : [];
packageManager.addDependencies({ ...npmOptions, packageJson }, [
...versionedPackages,
Expand Down
8 changes: 7 additions & 1 deletion lib/cli/src/js-package-manager/JsPackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import storybookPackagesVersions from '../versions.json';

const logger = console;

function getPackageDetails(pkg: string): [string, string?] {
/**
* Extract package name and version from input
*
* @param pkg A string like `@storybook/cli`, `react` or `react@^16`
* @return A tuple of 2 elements: [packageName, packageVersion]
*/
export function getPackageDetails(pkg: string): [string, string?] {
const idx = pkg.lastIndexOf('@');
// If the only `@` is the first character, it is a scoped package
// If it isn't in the string, it will be -1
Expand Down
108 changes: 54 additions & 54 deletions lib/cli/src/versions.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
{
"@storybook/addon-a11y": "6.2.0-alpha.26",
"@storybook/addon-actions": "6.2.0-alpha.26",
"@storybook/addon-backgrounds": "6.2.0-alpha.26",
"@storybook/addon-controls": "6.2.0-alpha.26",
"@storybook/addon-cssresources": "6.2.0-alpha.26",
"@storybook/addon-design-assets": "6.2.0-alpha.26",
"@storybook/addon-docs": "6.2.0-alpha.26",
"@storybook/addon-essentials": "6.2.0-alpha.26",
"@storybook/addon-events": "6.2.0-alpha.26",
"@storybook/addon-google-analytics": "6.2.0-alpha.26",
"@storybook/addon-graphql": "6.2.0-alpha.26",
"@storybook/addon-jest": "6.2.0-alpha.26",
"@storybook/addon-knobs": "6.2.0-alpha.26",
"@storybook/addon-links": "6.2.0-alpha.26",
"@storybook/addon-queryparams": "6.2.0-alpha.26",
"@storybook/addon-storyshots": "6.2.0-alpha.26",
"@storybook/addon-storyshots-puppeteer": "6.2.0-alpha.26",
"@storybook/addon-storysource": "6.2.0-alpha.26",
"@storybook/addon-toolbars": "6.2.0-alpha.26",
"@storybook/addon-viewport": "6.2.0-alpha.26",
"@storybook/addons": "6.2.0-alpha.26",
"@storybook/angular": "6.2.0-alpha.26",
"@storybook/api": "6.2.0-alpha.26",
"@storybook/aurelia": "6.2.0-alpha.26",
"@storybook/channel-postmessage": "6.2.0-alpha.26",
"@storybook/channel-websocket": "6.2.0-alpha.26",
"@storybook/channels": "6.2.0-alpha.26",
"@storybook/cli": "6.2.0-alpha.26",
"@storybook/client-api": "6.2.0-alpha.26",
"@storybook/client-logger": "6.2.0-alpha.26",
"@storybook/codemod": "6.2.0-alpha.26",
"@storybook/components": "6.2.0-alpha.26",
"@storybook/core": "6.2.0-alpha.26",
"@storybook/core-events": "6.2.0-alpha.26",
"@storybook/ember": "6.2.0-alpha.26",
"@storybook/html": "6.2.0-alpha.26",
"@storybook/marionette": "6.2.0-alpha.26",
"@storybook/marko": "6.2.0-alpha.26",
"@storybook/mithril": "6.2.0-alpha.26",
"@storybook/node-logger": "6.2.0-alpha.26",
"@storybook/postinstall": "6.2.0-alpha.26",
"@storybook/preact": "6.2.0-alpha.26",
"@storybook/rax": "6.2.0-alpha.26",
"@storybook/react": "6.2.0-alpha.26",
"@storybook/riot": "6.2.0-alpha.26",
"@storybook/router": "6.2.0-alpha.26",
"@storybook/server": "6.2.0-alpha.26",
"@storybook/source-loader": "6.2.0-alpha.26",
"@storybook/svelte": "6.2.0-alpha.26",
"@storybook/theming": "6.2.0-alpha.26",
"@storybook/ui": "6.2.0-alpha.26",
"@storybook/vue": "6.2.0-alpha.26",
"@storybook/vue3": "6.2.0-alpha.26",
"@storybook/web-components": "6.2.0-alpha.26"
"@storybook/addon-a11y": "6.2.0-alpha.27",
"@storybook/addon-actions": "6.2.0-alpha.27",
"@storybook/addon-backgrounds": "6.2.0-alpha.27",
"@storybook/addon-controls": "6.2.0-alpha.27",
"@storybook/addon-cssresources": "6.2.0-alpha.27",
"@storybook/addon-design-assets": "6.2.0-alpha.27",
"@storybook/addon-docs": "6.2.0-alpha.27",
"@storybook/addon-essentials": "6.2.0-alpha.27",
"@storybook/addon-events": "6.2.0-alpha.27",
"@storybook/addon-google-analytics": "6.2.0-alpha.27",
"@storybook/addon-graphql": "6.2.0-alpha.27",
"@storybook/addon-jest": "6.2.0-alpha.27",
"@storybook/addon-knobs": "6.2.0-alpha.27",
"@storybook/addon-links": "6.2.0-alpha.27",
"@storybook/addon-queryparams": "6.2.0-alpha.27",
"@storybook/addon-storyshots": "6.2.0-alpha.27",
"@storybook/addon-storyshots-puppeteer": "6.2.0-alpha.27",
"@storybook/addon-storysource": "6.2.0-alpha.27",
"@storybook/addon-toolbars": "6.2.0-alpha.27",
"@storybook/addon-viewport": "6.2.0-alpha.27",
"@storybook/addons": "6.2.0-alpha.27",
"@storybook/angular": "6.2.0-alpha.27",
"@storybook/api": "6.2.0-alpha.27",
"@storybook/aurelia": "6.2.0-alpha.27",
"@storybook/channel-postmessage": "6.2.0-alpha.27",
"@storybook/channel-websocket": "6.2.0-alpha.27",
"@storybook/channels": "6.2.0-alpha.27",
"@storybook/cli": "6.2.0-alpha.27",
"@storybook/client-api": "6.2.0-alpha.27",
"@storybook/client-logger": "6.2.0-alpha.27",
"@storybook/codemod": "6.2.0-alpha.27",
"@storybook/components": "6.2.0-alpha.27",
"@storybook/core": "6.2.0-alpha.27",
"@storybook/core-events": "6.2.0-alpha.27",
"@storybook/ember": "6.2.0-alpha.27",
"@storybook/html": "6.2.0-alpha.27",
"@storybook/marionette": "6.2.0-alpha.27",
"@storybook/marko": "6.2.0-alpha.27",
"@storybook/mithril": "6.2.0-alpha.27",
"@storybook/node-logger": "6.2.0-alpha.27",
"@storybook/postinstall": "6.2.0-alpha.27",
"@storybook/preact": "6.2.0-alpha.27",
"@storybook/rax": "6.2.0-alpha.27",
"@storybook/react": "6.2.0-alpha.27",
"@storybook/riot": "6.2.0-alpha.27",
"@storybook/router": "6.2.0-alpha.27",
"@storybook/server": "6.2.0-alpha.27",
"@storybook/source-loader": "6.2.0-alpha.27",
"@storybook/svelte": "6.2.0-alpha.27",
"@storybook/theming": "6.2.0-alpha.27",
"@storybook/ui": "6.2.0-alpha.27",
"@storybook/vue": "6.2.0-alpha.27",
"@storybook/vue3": "6.2.0-alpha.27",
"@storybook/web-components": "6.2.0-alpha.27"
}
4 changes: 2 additions & 2 deletions lib/core/src/server/__snapshots__/manager-dev
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Object {
Object {
"absoluteImports": "NODE_MODULES/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
"version": "3.8.3",
},
],
"NODE_MODULES/@babel/plugin-transform-template-literals/lib/index.js",
Expand Down Expand Up @@ -144,7 +144,7 @@ Object {
Object {
"absoluteImports": "NODE_MODULES/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
"version": "3.8.3",
},
],
],
Expand Down
4 changes: 2 additions & 2 deletions lib/core/src/server/__snapshots__/manager-prod
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Object {
Object {
"absoluteImports": "NODE_MODULES/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
"version": "3.8.3",
},
],
"NODE_MODULES/@babel/plugin-transform-template-literals/lib/index.js",
Expand Down Expand Up @@ -144,7 +144,7 @@ Object {
Object {
"absoluteImports": "NODE_MODULES/core-js/index.js",
"method": "usage-global",
"version": "3.8.2",
"version": "3.8.3",
},
],
],
Expand Down
Loading

0 comments on commit 1b87b77

Please sign in to comment.