From e3f78c0561c609dea97f6e48d71d3a0c40602c30 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Fri, 21 Apr 2023 12:57:07 -0500 Subject: [PATCH 1/4] wip --- .github/CONTRIBUTING.md | 2 ++ .github/workflows/ci.yml | 11 +++++++---- .nvmrc | 2 +- package.json | 2 +- tsconfig.json | 17 ++++++++++------- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b27305fc..f12ce6e7 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -17,6 +17,8 @@ Have an idea for improving Typewriter? [Submit an issue first](https://github.co ### Build and run locally ```sh +# Use node version defined in .nvmrc +$ nvm use # Install dependencies $ yarn # Test your Typewriter installation by regenerating Typewriter's typewriter client. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b6a25aa..a3cea94a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,12 +15,15 @@ jobs: build-and-test: needs: cancel_previous runs-on: 'ubuntu-latest' + strategy: + matrix: + node-version: [ 14, 16, 18 ] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: - node-version: '16' - cache: 'yarn' + node-version: ${{ matrix.node-version }} + cache: yarn - name: Install run: yarn install --frozen-lockfile - name: Lint diff --git a/.nvmrc b/.nvmrc index f599e28b..8351c193 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -10 +14 diff --git a/package.json b/package.json index a6122fbc..1274425e 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "version": "oclif readme && git add README.md" }, "engines": { - "node": ">=12.0.0" + "node": ">=14" }, "keywords": [ "oclif", diff --git a/tsconfig.json b/tsconfig.json index 10048058..fabef5f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,17 +1,20 @@ { "compilerOptions": { - "declaration": true, - "allowSyntheticDefaultImports": true, + // https://www.npmjs.com/package/@tsconfig/node14 + "lib": ["es2020"], + "module": "commonjs", + "target": "es2020", + "strict": true, "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node", + + "allowSyntheticDefaultImports": true, "resolveJsonModule": true, "importHelpers": true, - "moduleResolution": "node", "outDir": "dist", "rootDir": "src", - "module": "CommonJS", - "strict": true, - "target": "es2019", - "skipLibCheck": true }, "include": ["src/**/*"], "exclude": ["src/languages/templates/**/*"] From 22b9895fbcd8ccfe2109f8aad67a4c83f7dd3616 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:02:20 -0500 Subject: [PATCH 2/4] fix test --- .../commands/__snapshots__/build.test.ts.snap | 10 +++++----- src/__tests__/commands/build.test.ts | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/__tests__/commands/__snapshots__/build.test.ts.snap b/src/__tests__/commands/__snapshots__/build.test.ts.snap index 092fe09e..a35f3d8d 100644 --- a/src/__tests__/commands/__snapshots__/build.test.ts.snap +++ b/src/__tests__/commands/__snapshots__/build.test.ts.snap @@ -105,7 +105,7 @@ function validateAgainstSchema(message, schema) { function withTypewriterContext(message) { return __assign(__assign({}, message), { context: __assign(__assign({}, (message.context || {})), { typewriter: { language: 'typescript', - version: '8.0.10', + } }) }); } /** @@ -5363,7 +5363,7 @@ function withTypewriterContext(message: Options = {}): Options { ...(message.context || {}), typewriter: { language: 'typescript', - version: '8.0.10', + }, }, }; @@ -6892,7 +6892,7 @@ function withTypewriterContext
>( ...(message.context || {}), typewriter: { language: 'typescript', - version: '8.0.10', + }, }, } @@ -8466,7 +8466,7 @@ function withTypewriterContext
>( ...(message.context || {}), typewriter: { language: 'typescript', - version: '8.0.10', + }, }, } @@ -10001,7 +10001,7 @@ function withTypewriterContext
>( ...(message.context || {}), typewriter: { language: 'typescript', - version: '8.0.10', + }, }, } diff --git a/src/__tests__/commands/build.test.ts b/src/__tests__/commands/build.test.ts index 41a11242..c669d720 100644 --- a/src/__tests__/commands/build.test.ts +++ b/src/__tests__/commands/build.test.ts @@ -48,11 +48,12 @@ describe("build", () => { legacyId ); const { stdout } = await run(["build", "-c", testPath]); - expect( - fs.readFileSync(path.join(testPath, filename), { + const output = fs + .readFileSync(path.join(testPath, filename), { encoding: "utf-8", }) - ).toMatchSnapshot(); + .replace(/version:.*\d.*/g, ""); + expect(output).toMatchSnapshot(); }); } }); From f4000b3d68e15551bb2248ddbbaa297bd5ff8816 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:03:16 -0500 Subject: [PATCH 3/4] update test name --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3cea94a..de26acb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,7 @@ jobs: with: workflow_id: ${{ github.event.workflow.id }} build-and-test: + name: "Test (Node.js v${{ matrix.node-version }})" needs: cancel_previous runs-on: 'ubuntu-latest' strategy: From e37da43f4bd611631e1645d74360ae7d91804841 Mon Sep 17 00:00:00 2001 From: Seth Silesky <5115498+silesky@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:06:45 -0500 Subject: [PATCH 4/4] fix tet --- .../commands/__snapshots__/production.test.ts.snap | 4 ++-- src/__tests__/commands/production.test.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/__tests__/commands/__snapshots__/production.test.ts.snap b/src/__tests__/commands/__snapshots__/production.test.ts.snap index 6425c2e2..a85d4050 100644 --- a/src/__tests__/commands/__snapshots__/production.test.ts.snap +++ b/src/__tests__/commands/__snapshots__/production.test.ts.snap @@ -852,7 +852,7 @@ function withTypewriterContext(message: Options = {}): Options { ...(message.context || {}), typewriter: { language: 'typescript', - version: '8.0.10', + }, }, }; @@ -2322,7 +2322,7 @@ function withTypewriterContext
>( ...(message.context || {}), typewriter: { language: 'typescript', - version: '8.0.10', + }, }, } diff --git a/src/__tests__/commands/production.test.ts b/src/__tests__/commands/production.test.ts index 958e41c2..afcc2726 100644 --- a/src/__tests__/commands/production.test.ts +++ b/src/__tests__/commands/production.test.ts @@ -25,11 +25,12 @@ describe("prod", () => { legacyId ); await run(["production", "-c", testPath]); - expect( - fs.readFileSync(path.join(testPath, filename), { - encoding: "utf-8", - }) - ).toMatchSnapshot(); + const output = fs + .readFileSync(path.join(testPath, filename), { + encoding: "utf-8", + }) + .replace(/version:.*\d.*/g, "") + expect(output).toMatchSnapshot(); }); } });