mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 04:31:06 +08:00
move version.json
This commit is contained in:
parent
e717ab1f8b
commit
0930e4d8d3
@ -38,7 +38,7 @@
|
|||||||
"versions.json"
|
"versions.json"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "node ../../scripts/prepare.js && node ./scripts/generate-sb-packages-versions.js",
|
"prepare": "node ./scripts/generate-sb-packages-versions.js && node ../../scripts/prepare.js",
|
||||||
"test": "jest test/**/*.test.js",
|
"test": "jest test/**/*.test.js",
|
||||||
"postversion": "node ./scripts/generate-sb-packages-versions.js"
|
"postversion": "node ./scripts/generate-sb-packages-versions.js"
|
||||||
},
|
},
|
||||||
|
@ -32,7 +32,9 @@ const run = async () => {
|
|||||||
.sort((package1, package2) => package1.name.localeCompare(package2.name))
|
.sort((package1, package2) => package1.name.localeCompare(package2.name))
|
||||||
.reduce((acc, { name, version }) => ({ ...acc, [name]: version }), {});
|
.reduce((acc, { name, version }) => ({ ...acc, [name]: version }), {});
|
||||||
|
|
||||||
await writeJson(path.join(__dirname, '..', 'versions.json'), packageToVersionMap, { spaces: 2 });
|
await writeJson(path.join(__dirname, '..', 'src', 'versions.json'), packageToVersionMap, {
|
||||||
|
spaces: 2,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
run().catch((e) => {
|
run().catch((e) => {
|
||||||
|
@ -4,10 +4,9 @@ import { sync as spawnSync } from 'cross-spawn';
|
|||||||
import { commandLog } from '../helpers';
|
import { commandLog } from '../helpers';
|
||||||
import { PackageJson, PackageJsonWithDepsAndDevDeps } from './PackageJson';
|
import { PackageJson, PackageJsonWithDepsAndDevDeps } from './PackageJson';
|
||||||
import { readPackageJson, writePackageJson } from './PackageJsonHelper';
|
import { readPackageJson, writePackageJson } from './PackageJsonHelper';
|
||||||
|
import storybookPackagesVersions from '../versions.json';
|
||||||
|
|
||||||
const logger = console;
|
const logger = console;
|
||||||
// Cannot be `import` as it's not under TS root dir
|
|
||||||
const storybookPackagesVersions = require('../../versions.json');
|
|
||||||
|
|
||||||
export abstract class JsPackageManager {
|
export abstract class JsPackageManager {
|
||||||
public abstract readonly type: 'npm' | 'yarn1' | 'yarn2';
|
public abstract readonly type: 'npm' | 'yarn1' | 'yarn2';
|
||||||
@ -137,9 +136,10 @@ export abstract class JsPackageManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getVersion(packageName: string, constraint?: string): Promise<string> {
|
public async getVersion(packageName: string, constraint?: string): Promise<string> {
|
||||||
let current;
|
let current: string;
|
||||||
|
|
||||||
if (/@storybook/.test(packageName)) {
|
if (/@storybook/.test(packageName)) {
|
||||||
|
// @ts-ignore
|
||||||
current = storybookPackagesVersions[packageName];
|
current = storybookPackagesVersions[packageName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ describe('NPM Proxy', () => {
|
|||||||
describe('getVersion', () => {
|
describe('getVersion', () => {
|
||||||
it('with a Storybook package listed in versions.json it returns the version', async () => {
|
it('with a Storybook package listed in versions.json it returns the version', async () => {
|
||||||
// eslint-disable-next-line global-require
|
// eslint-disable-next-line global-require
|
||||||
const storybookAngularVersion = require('../../versions.json')['@storybook/angular'];
|
const storybookAngularVersion = require('../versions.json')['@storybook/angular'];
|
||||||
const executeCommandSpy = jest.spyOn(npmProxy, 'executeCommand').mockReturnValue('"5.3.19"');
|
const executeCommandSpy = jest.spyOn(npmProxy, 'executeCommand').mockReturnValue('"5.3.19"');
|
||||||
|
|
||||||
const version = await npmProxy.getVersion('@storybook/angular');
|
const version = await npmProxy.getVersion('@storybook/angular');
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"noUnusedParameters": true,
|
"noUnusedParameters": true,
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
"noFallthroughCasesInSwitch": true
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"],
|
"include": ["src/**/*"],
|
||||||
"exclude": ["src/**/template*", "src/frameworks/**/*"]
|
"exclude": ["src/**/template*", "src/frameworks/**/*"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user