Skip to content

Commit

Permalink
move version.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen committed Dec 9, 2020
1 parent e717ab1 commit 0930e4d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 3 additions & 1 deletion lib/cli/scripts/generate-sb-packages-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions lib/cli/src/js-package-manager/JsPackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/cli/src/js-package-manager/NPMProxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion lib/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true
},
"include": ["src/**/*"],
"exclude": ["src/**/template*", "src/frameworks/**/*"]
Expand Down

0 comments on commit 0930e4d

Please sign in to comment.