From c558aef3d9f068dd93a049ed877a2b9c9da631bb Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 8 Dec 2022 09:40:39 +0100 Subject: [PATCH 1/2] migrate addonstoryshots away from the prepare script and use tsc directly similar to frameworks/angular Co-authored-by: Kasper Peulen --- .../storyshots/storyshots-core/package.json | 6 ++--- .../storyshots-core/tsconfig.build.json | 22 +++++++++++++++++++ .../storyshots-puppeteer/package.json | 5 +++-- .../storyshots-puppeteer/tsconfig.build.json | 22 +++++++++++++++++++ code/yarn.lock | 2 ++ 5 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 code/addons/storyshots/storyshots-core/tsconfig.build.json create mode 100644 code/addons/storyshots/storyshots-puppeteer/tsconfig.build.json diff --git a/code/addons/storyshots/storyshots-core/package.json b/code/addons/storyshots/storyshots-core/package.json index e97ea6533fbf..1871b7829985 100644 --- a/code/addons/storyshots/storyshots-core/package.json +++ b/code/addons/storyshots/storyshots-core/package.json @@ -31,10 +31,7 @@ "*.d.ts" ], "scripts": { - "build-storybook": "sb build", - "example": "jest storyshot.test", - "prep": "node ../../../../scripts/prepare.js", - "storybook": "yarn sb dev -p 6006" + "prep": "rimraf dist && ../../../../scripts/node_modules/.bin/tsc --project tsconfig.build.json && echo \"Preventing passing flags to tsc\"" }, "dependencies": { "@jest/transform": "^29.3.1", @@ -71,6 +68,7 @@ "jest-preset-angular": "^8.3.2", "jest-vue-preprocessor": "^1.7.1", "react-test-renderer": "^16", + "rimraf": "^3.0.2", "rxjs": "^6.6.3", "vue-jest": "^5.0.0-alpha.8" }, diff --git a/code/addons/storyshots/storyshots-core/tsconfig.build.json b/code/addons/storyshots/storyshots-core/tsconfig.build.json new file mode 100644 index 000000000000..6aa09e55adac --- /dev/null +++ b/code/addons/storyshots/storyshots-core/tsconfig.build.json @@ -0,0 +1,22 @@ +{ + "extends": "../../tsconfig.json", + "compileOnSave": false, + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "lib": ["es2020", "dom"], + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "declaration": true, + "outDir": "dist", + "types": ["node"], + "skipLibCheck": true, + "resolveJsonModule": true, + "allowJs": true, + "pretty": true, + "noErrorTruncation": true, + "listEmittedFiles": false, + "noUnusedLocals": false + }, + "include": ["src/**/*", "src/**/*.json"] +} diff --git a/code/addons/storyshots/storyshots-puppeteer/package.json b/code/addons/storyshots/storyshots-puppeteer/package.json index e834093122b0..0dae68f39682 100644 --- a/code/addons/storyshots/storyshots-puppeteer/package.json +++ b/code/addons/storyshots/storyshots-puppeteer/package.json @@ -30,7 +30,7 @@ "*.d.ts" ], "scripts": { - "prep": "node ../../../../scripts/prepare.js" + "prep": "rimraf dist && ../../../../scripts/node_modules/.bin/tsc --project tsconfig.build.json && echo \"Preventing passing flags to tsc\"" }, "dependencies": { "@axe-core/puppeteer": "^4.2.0", @@ -42,7 +42,8 @@ }, "devDependencies": { "@types/puppeteer": "^5.4.0", - "puppeteer": "^2.0.0 || ^3.0.0" + "puppeteer": "^2.0.0 || ^3.0.0", + "rimraf": "^3.0.2" }, "peerDependencies": { "@storybook/addon-storyshots": "7.0.0-alpha.62", diff --git a/code/addons/storyshots/storyshots-puppeteer/tsconfig.build.json b/code/addons/storyshots/storyshots-puppeteer/tsconfig.build.json new file mode 100644 index 000000000000..6aa09e55adac --- /dev/null +++ b/code/addons/storyshots/storyshots-puppeteer/tsconfig.build.json @@ -0,0 +1,22 @@ +{ + "extends": "../../tsconfig.json", + "compileOnSave": false, + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "lib": ["es2020", "dom"], + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "declaration": true, + "outDir": "dist", + "types": ["node"], + "skipLibCheck": true, + "resolveJsonModule": true, + "allowJs": true, + "pretty": true, + "noErrorTruncation": true, + "listEmittedFiles": false, + "noUnusedLocals": false + }, + "include": ["src/**/*", "src/**/*.json"] +} diff --git a/code/yarn.lock b/code/yarn.lock index 5216b3bc46c3..ed1b850b3a05 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5464,6 +5464,7 @@ __metadata: "@types/puppeteer": ^5.4.0 jest-image-snapshot: ^6.0.0 puppeteer: ^2.0.0 || ^3.0.0 + rimraf: ^3.0.2 peerDependencies: "@storybook/addon-storyshots": 7.0.0-alpha.62 puppeteer: ">=2.0.0" @@ -5507,6 +5508,7 @@ __metadata: pretty-format: ^29.0.0 react-test-renderer: ^16 read-pkg-up: ^7.0.1 + rimraf: ^3.0.2 rxjs: ^6.6.3 ts-dedent: ^2.0.0 vue-jest: ^5.0.0-alpha.8 From a99310db89e5b228b16d9c73e644eb27db029a88 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 8 Dec 2022 09:55:32 +0100 Subject: [PATCH 2/2] fixes --- .../storyshots-core/src/api/integrityTestTemplate.ts | 1 + code/addons/storyshots/storyshots-core/tsconfig.build.json | 3 ++- code/addons/storyshots/storyshots-core/tsconfig.json | 3 +-- .../addons/storyshots/storyshots-puppeteer/tsconfig.build.json | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts b/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts index d52260268104..d1c5bdb6e627 100644 --- a/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts +++ b/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts @@ -52,6 +52,7 @@ function integrityTest(integrityOptions: any, stories2snapsConverter: any) { const snapshotExtension = stories2snapsConverter.getSnapshotExtension(); const storyshots = glob.sync(`**/*${snapshotExtension}`, integrityOptions); + // @ts-expect-error (ts doesn't 'get' the extension happening on line 9) expect(storyshots).notToBeAbandoned(stories2snapsConverter); }); }); diff --git a/code/addons/storyshots/storyshots-core/tsconfig.build.json b/code/addons/storyshots/storyshots-core/tsconfig.build.json index 6aa09e55adac..dae6c1e39197 100644 --- a/code/addons/storyshots/storyshots-core/tsconfig.build.json +++ b/code/addons/storyshots/storyshots-core/tsconfig.build.json @@ -1,10 +1,11 @@ { - "extends": "../../tsconfig.json", + "extends": "./tsconfig.json", "compileOnSave": false, "compilerOptions": { "target": "ES2020", "module": "CommonJS", "lib": ["es2020", "dom"], + "esModuleInterop": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "declaration": true, diff --git a/code/addons/storyshots/storyshots-core/tsconfig.json b/code/addons/storyshots/storyshots-core/tsconfig.json index a0c810473aef..769c52947576 100644 --- a/code/addons/storyshots/storyshots-core/tsconfig.json +++ b/code/addons/storyshots/storyshots-core/tsconfig.json @@ -4,8 +4,7 @@ "declaration": true, "jsx": "preserve", "skipLibCheck": true, - "skipDefaultLibCheck": true, - "types": ["jest", "testing-library__jest-dom"] + "skipDefaultLibCheck": true }, "include": ["src/**/*.ts"] } diff --git a/code/addons/storyshots/storyshots-puppeteer/tsconfig.build.json b/code/addons/storyshots/storyshots-puppeteer/tsconfig.build.json index 6aa09e55adac..dae6c1e39197 100644 --- a/code/addons/storyshots/storyshots-puppeteer/tsconfig.build.json +++ b/code/addons/storyshots/storyshots-puppeteer/tsconfig.build.json @@ -1,10 +1,11 @@ { - "extends": "../../tsconfig.json", + "extends": "./tsconfig.json", "compileOnSave": false, "compilerOptions": { "target": "ES2020", "module": "CommonJS", "lib": ["es2020", "dom"], + "esModuleInterop": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "declaration": true,