diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml new file mode 100644 index 0000000..51f832f --- /dev/null +++ b/.github/workflows/ci-test.yml @@ -0,0 +1,26 @@ +name: Node.js CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [windows-latest] # ubuntu-latest, mac-latest + + steps: + - uses: actions/checkout@v3 + + - name: Use Node LTS + uses: actions/setup-node@v3 + + with: + node-version: lts/* + - run: npm ci + - run: npm test \ No newline at end of file diff --git a/cli.js b/cli.js index 34c4179..2f560ad 100644 --- a/cli.js +++ b/cli.js @@ -66,6 +66,7 @@ console.log(`\nRunning ${pc.green(`${pc.bold('mkcert-cli')}`)} (${pkgVersion})\n (dryRun || verbose) && console.log(`${pc.bold('With options:')} - ${pc.blue('cwd')}: ${pc.yellow(cwd)} + - ${pc.blue('dataDir')}: ${pc.yellow(DATA_DIR)} - ${pc.blue('outDir')}: ${pc.yellow(outDir)} - ${pc.blue('hosts')}: ${JSON.stringify(hosts)} - ${pc.blue('cert')}: ${certFile} diff --git a/package.json b/package.json index bd98215..2f64d06 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "src/" ], "scripts": { - "test": "npx -y rome check . && vitest run", + "test": "npx -y rome check . && vitest run --reporter verbose", "tdd": "vitest", "fix": "npx -y rome format . --write", "publish:dev": "npx -y np prerelease --tag=next --any-branch --no-release-draft", diff --git a/test/utils.test.js b/test/utils.test.js index 220680c..54b4fa2 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -5,7 +5,28 @@ import pkgJson from '../package.json' assert { type: 'json' }; import { dirname, join, resolve } from 'path'; import { homedir } from 'os'; -describe('semverGreaterThan', () => { +const cliPath = resolve(join(dirname(new URL(import.meta.url).pathname), '../cli.js')); + +describe('--dryRun', () => { + it('more of a debug print session for CI', async () => { + + const cmd = `node ${cliPath} --dryRun`; + console.log('PLEASE READ THIS', { + cwd: process.cwd(), + cliPath, + importURL: import.meta.url, + filePathURL: new URL('..cli.js', import.meta.url).toString(), + filePathResolve: resolve('../cli.js'), + resolveJoinDirname: resolve(join(dirname(import.meta.url), '../cli.js')), + }); + const { stdout } = await exec(cmd, { cwd: homedir(), env: { ...process.env } }); + console.log(` + ${stdout} + `); + }); +}); + +describe.skip('semverGreaterThan', () => { it('returns expected bool', () => { assert.ok(semverGreaterThan('v1.4.4', 'v.1.4.3')); assert.notOk(semverGreaterThan('v1.4.3', 'v.1.4.4')); @@ -13,24 +34,23 @@ describe('semverGreaterThan', () => { }); }); -describe('pkgJson', () => { +describe.skip('pkgJson', () => { it('matches asserted import value', () => { assert.equal(pkgVersion, `v${pkgJson.version}`); }); it('cli.js --version, also works from random directory', async () => { - const cliPathAbs = getAbsolutePath('../cli.js', import.meta.url); - const cmd = `node ${cliPathAbs} --version`; + const cmd = `node ${cliPath} --version`; const { stdout } = await exec(cmd, { cwd: homedir(), env: { ...process.env } }); assert.equal(pkgVersion, `${stdout.trim()}`); }); }); const testCertFolder = 'tstCertFolder'; -const cmd = `node ${join(dirname(import.meta.url), '../cli.js').replace(/^file:/, '')}`; +const cmd = `node ${cliPath}`; const rmTestDir = async () => await exec(`rm -rf ${testCertFolder}`, {}); -describe('cli', () => { +describe.skip('cli', () => { beforeEach(async () => { await rmTestDir(); });