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"
],
"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",
"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))
.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) => {

View File

@ -4,10 +4,9 @@ import { sync as spawnSync } from 'cross-spawn';
import { commandLog } from '../helpers';
import { PackageJson, PackageJsonWithDepsAndDevDeps } from './PackageJson';
import { readPackageJson, writePackageJson } from './PackageJsonHelper';
import storybookPackagesVersions from '../versions.json';
const logger = console;
// Cannot be `import` as it's not under TS root dir
const storybookPackagesVersions = require('../../versions.json');
export abstract class JsPackageManager {
public abstract readonly type: 'npm' | 'yarn1' | 'yarn2';
@ -137,9 +136,10 @@ export abstract class JsPackageManager {
}
public async getVersion(packageName: string, constraint?: string): Promise<string> {
let current;
let current: string;
if (/@storybook/.test(packageName)) {
// @ts-ignore
current = storybookPackagesVersions[packageName];
}

View File

@ -86,7 +86,7 @@ describe('NPM Proxy', () => {
describe('getVersion', () => {
it('with a Storybook package listed in versions.json it returns the version', async () => {
// 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 version = await npmProxy.getVersion('@storybook/angular');

View File

@ -9,7 +9,8 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/template*", "src/frameworks/**/*"]