update got dependency and convert to esm module (#533)

* update require got to import got

* convert remaining to esm

* wip: replace jest with vitest

* fix test imports and vitest config

* remove dist package.json

* fix import in ent test

* add dist

* move actions/core to prod dependency

* remove unused import that was breaking esm compilation

* simplify imports

* use module.createRequire to import jsonata

* add doc link comment

* add comments on import insanity

* add more comments

* update PR tempalte

* bump got and remove jest deps

* revert debug npm run command

* fix fs import

* simplify vitest config for each test suite
This commit is contained in:
John-Michael Faircloth 2024-03-19 10:42:34 -05:00 committed by GitHub
parent a727ce205a
commit 77efb36ae3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 12213 additions and 14317 deletions

View file

@ -1,11 +1,12 @@
jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
const core = require('@actions/core');
import { vi, describe, test, expect } from 'vitest';
const got = require('got');
const { when } = require('jest-when');
vi.mock('@actions/core');
import core from '@actions/core';
const { exportSecrets } = require('../../src/action');
import got from 'got';
import { when } from 'jest-when'
import { exportSecrets } from '../../src/action.js';
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
@ -102,7 +103,7 @@ describe('authenticate with approle', () => {
});
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('method', expect.anything())

View file

@ -1,11 +1,12 @@
jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
const core = require('@actions/core');
import { vi, describe, test, expect } from 'vitest';
const got = require('got');
const { when } = require('jest-when');
vi.mock('@actions/core');
import core from '@actions/core';
const { exportSecrets } = require('../../src/action');
import got from 'got';
import { when } from 'jest-when'
import { exportSecrets } from '../../src/action.js';
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
@ -107,7 +108,7 @@ describe('integration', () => {
});
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('url', expect.anything())

View file

@ -1,3 +0,0 @@
module.exports = {
verbose: true
};

View file

@ -1,17 +1,18 @@
jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
const core = require('@actions/core');
const rsasign = require('jsrsasign');
const {
import { vi, describe, test, expect } from 'vitest';
vi.mock('@actions/core');
import core from '@actions/core';
import rsasign from 'jsrsasign';
import {
privateRsaKey,
privateRsaKeyBase64,
publicRsaKey
} = require('./rsa_keys');
} from './rsa_keys.js';
const got = require('got');
const { when } = require('jest-when');
import got from 'got';
import { when } from 'jest-when'
const { exportSecrets } = require('../../src/action');
import { exportSecrets } from '../../src/action.js';
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
@ -139,7 +140,7 @@ describe('jwt auth', () => {
describe('authenticate with private key', () => {
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('url', expect.anything())
@ -189,7 +190,7 @@ describe('jwt auth', () => {
})
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('url', expect.anything())

View file

@ -42,7 +42,7 @@ LrJEY9tZaRF8xraMZiOcBcyAt6S/TS29HttJ6+zlhcWx34fItEZ8jA5gzhTmspOY
-----END PUBLIC KEY-----
`;
module.exports = {
export {
privateRsaKey,
privateRsaKeyBase64,
publicRsaKey

View file

@ -1,11 +1,12 @@
jest.mock('@actions/core');
jest.mock('@actions/core/lib/command');
const core = require('@actions/core');
import { vi, describe, test, expect } from 'vitest';
const got = require('got');
const { when } = require('jest-when');
vi.mock('@actions/core');
import core from '@actions/core';
const { exportSecrets } = require('../../src/action');
import got from 'got';
import { when } from 'jest-when'
import { exportSecrets } from '../../src/action.js';
const vaultUrl = `http://${process.env.VAULT_HOST || 'localhost'}:${process.env.VAULT_PORT || '8200'}`;
const vaultToken = `${process.env.VAULT_TOKEN || 'testtoken'}`
@ -84,7 +85,7 @@ describe('authenticate with userpass', () => {
});
beforeEach(() => {
jest.resetAllMocks();
vi.resetAllMocks();
when(core.getInput)
.calledWith('method', expect.anything())

View file

@ -0,0 +1,11 @@
import { defineConfig, configDefaults } from 'vitest/config'
export default defineConfig({
test: {
// required to make jest-when work with vitest
globals: true,
include: [
'**/integrationTests/basic/**.{test,spec}.?(c|m)[jt]s?(x)',
],
},
})