move version.json

This commit is contained in:
Norbert de Langen 2020-12-09 13:23:02 +01:00
parent e717ab1f8b
commit 0930e4d8d3
No known key found for this signature in database
GPG Key ID: 976651DA156C2825
6 changed files with 10 additions and 7 deletions

View File

@ -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"
}, },

View File

@ -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) => {

View File

@ -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];
} }

View File

@ -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');

View File

@ -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/**/*"]