Skip to content

Commit

Permalink
refactor to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
siggerzz committed Feb 9, 2024
1 parent 1c1f53d commit 20b4c9e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changeset-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
github-token: ${{ secrets.CHANGESETS_TOKEN }}
script: |
const execa = require('execa');
const script = require('./.github/workflows/changeset-snapshot/create-and-publish.js')
const script = require('./.github/workflows/changeset-snapshot/create-and-publish.mjs')
await script({ github, context }, execa);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { Octokit } = require("@octokit/rest");
const fetch = require('node-fetch');
import { Octokit } from '@octokit/rest';
import fetch from 'node-fetch';

module.exports = async ({ github, context }, execa) => {
const createAndPublish = async ({ github, context }, execa) => {
await execa.command('yarn changeset:version --snapshot snapshot-release', { stdio: 'inherit' });

const releaseProcess = execa.command('yarn changeset:publish --no-git-tags --snapshot --tag snapshot-release');
Expand Down Expand Up @@ -71,3 +71,7 @@ yarn up ${newTags[0]}
body,
});
};

export {
createAndPublish
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, test, vi } from 'vitest';
const workflow = require('../create-and-publish');
const { Readable } = require('stream');
import { createAndPublish } from '../create-and-publish.mjs';
import { Readable } from 'stream';

let context;
let execa;
Expand Down Expand Up @@ -63,7 +63,7 @@ describe('create and publish workflow', () => {

test('should create a github comment', async () => {
// Act
await workflow({ context, github }, execa);
await createAndPublish({ context, github }, execa);

// Assert
expect(github.rest.issues.createComment).toHaveBeenCalledTimes(1);
Expand All @@ -75,7 +75,7 @@ describe('create and publish workflow', () => {
sampleOutput = '';

// Act
await workflow({ context, github }, execa);
await createAndPublish({ context, github }, execa);

// Assert
expect(expectedBody.startsWith('No changed packages found!')).toBe(true);
Expand All @@ -92,7 +92,7 @@ describe('create and publish workflow', () => {
`;

// Act
await workflow({ context, github }, execa);
await createAndPublish({ context, github }, execa);

// Assert
expect(expectedBody).toMatchSnapshot();
Expand All @@ -106,7 +106,7 @@ describe('create and publish workflow', () => {
`;

// Act
await workflow({ context, github }, execa);
await createAndPublish({ context, github }, execa);

// Assert
expect(expectedBody).toMatchSnapshot();
Expand All @@ -121,7 +121,7 @@ describe('create and publish workflow', () => {
`;

// Act
await workflow({ context, github }, execa);
await createAndPublish({ context, github }, execa);

// Assert
expect(expectedBody).toMatchSnapshot();
Expand All @@ -137,7 +137,7 @@ describe('create and publish workflow', () => {
`;

// Act
await workflow({ context, github }, execa);
await createAndPublish({ context, github }, execa);

// Assert
expect(expectedBody).toMatchSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@
},
"dependencies": {
"@octokit/rest": "20.0.2",
"node-fetch": "2"
"node-fetch": "^3.3.2"
}
}
32 changes: 16 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27274,20 +27274,6 @@ __metadata:
languageName: node
linkType: hard

"node-fetch@npm:2, node-fetch@npm:^2.0.0, node-fetch@npm:^2.5.0, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.7":
version: 2.7.0
resolution: "node-fetch@npm:2.7.0"
dependencies:
whatwg-url: ^5.0.0
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5
languageName: node
linkType: hard

"node-fetch@npm:2.6.1":
version: 2.6.1
resolution: "node-fetch@npm:2.6.1"
Expand All @@ -27309,7 +27295,21 @@ __metadata:
languageName: node
linkType: hard

"node-fetch@npm:^3.2.8":
"node-fetch@npm:^2.0.0, node-fetch@npm:^2.5.0, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.7":
version: 2.7.0
resolution: "node-fetch@npm:2.7.0"
dependencies:
whatwg-url: ^5.0.0
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5
languageName: node
linkType: hard

"node-fetch@npm:^3.2.8, node-fetch@npm:^3.3.2":
version: 3.3.2
resolution: "node-fetch@npm:3.3.2"
dependencies:
Expand Down Expand Up @@ -29039,7 +29039,7 @@ __metadata:
glob: 10.3.3
husky: 8.0.3
jsdom: 24.0.0
node-fetch: 2
node-fetch: ^3.3.2
npm-run-all: 4.1.5
pinst: 3.0.0
postcss: 8.4.32
Expand Down

0 comments on commit 20b4c9e

Please sign in to comment.