Skip to content

Commit

Permalink
Merge branch 'feat/extend-cmd-program' into release/cmd-1.1.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
twk3 committed Sep 25, 2024
2 parents 39f59a2 + 87f2373 commit d809072
Show file tree
Hide file tree
Showing 120 changed files with 1,368 additions and 1,342 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ['custom'],
extends: ["custom"],
};
8 changes: 4 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ on:
type: choice
description: Package to publish
options:
- '@currents/cmd'
- '@currents/jest'
- "@currents/cmd"
- "@currents/jest"

jobs:
publish:
Expand All @@ -35,8 +35,8 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

- run: npm ci
- name: Publish to NPM
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on:
jobs:
currentsUnitTests:
if: "!contains(toJSON(github.event.commits.*.message), '[skip ci]')"
name: 'Unit Tests'
name: "Unit Tests"
runs-on: ubuntu-22.04
container: mcr.microsoft.com/playwright:v1.28.1-focal
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
node-version: "20.x"
cache: "npm"

- name: Install dependencies
run: |
Expand Down
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

10 changes: 5 additions & 5 deletions examples/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};
presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
],
};
10 changes: 5 additions & 5 deletions examples/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
const config = {
reporters: [
// "default",
['@currents/jest', {}],
["@currents/jest", {}],
],
projects: [
{
displayName: 'spec',
displayName: "spec",
testLocationInResults: true,
testMatch: ['<rootDir>/**/*.spec.ts'],
testMatch: ["<rootDir>/**/*.spec.ts"],
},
{
displayName: 'test',
displayName: "test",
testLocationInResults: true,
testMatch: ['<rootDir>/**/*.test.ts'],
testMatch: ["<rootDir>/**/*.test.ts"],
},
],
};
Expand Down
14 changes: 7 additions & 7 deletions examples/src/basic/basic.spec.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
describe('describe block 1', () => {
it('expect 1 to match 1', () => {
describe("describe block 1", () => {
it("expect 1 to match 1", () => {
expect(1).toBe(1);
});

it.todo('todo test');
it.todo("todo test");

it.skip('skipped test case', () => {
it.skip("skipped test case", () => {
expect(2).toBe(2);
});
});

describe.skip('skipped describe block', () => {
it('expect 3 to match 3', () => {
describe.skip("skipped describe block", () => {
it("expect 3 to match 3", () => {
expect(3).toBe(3);
});

it('expect 4 to match 4', () => {
it("expect 4 to match 4", () => {
expect(4).toBe(4);
});
});
14 changes: 7 additions & 7 deletions examples/src/basic/basic2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
describe('describe parent', () => {
describe('describe block 3', () => {
it('expect 1 to match 1', () => {
describe("describe parent", () => {
describe("describe block 3", () => {
it("expect 1 to match 1", () => {
expect(1).toBe(1);
});

it('expect 2 to match 2', () => {
it("expect 2 to match 2", () => {
expect(2).toBe(2);
});
});

describe('describe block 4', () => {
it('expect 3 to match 3', () => {
describe("describe block 4", () => {
it("expect 3 to match 3", () => {
expect(3).toBe(3);
});

it('expect 4 to match 4', () => {
it("expect 4 to match 4", () => {
expect(4).toBe(4);
});
});
Expand Down
4 changes: 2 additions & 2 deletions examples/src/basic/delay.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('delay', () => {
test('example test', async () => {
describe("delay", () => {
test("example test", async () => {
await new Promise((resolve) => setTimeout(resolve, 2000));
expect(true).toBe(true);
});
Expand Down
4 changes: 2 additions & 2 deletions examples/src/basic/sum.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sum } from './sum';
import { sum } from "./sum";

test('adds 1 + 2 to equal 3', () => {
test("adds 1 + 2 to equal 3", () => {
expect(sum(1, 2)).toBe(3);
});
4 changes: 2 additions & 2 deletions examples/src/basic/sum.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function sum(a, b) {
return a + b;
}
return a + b;
}
6 changes: 3 additions & 3 deletions examples/src/flaky.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
jest.retryTimes(2);
let j = 0;
describe('Flaky', () => {
it('should pass only on second run', async () => {
describe("Flaky", () => {
it("should pass only on second run", async () => {
expect(j++).toEqual(1);
});

it('AAA', async () => {
it("AAA", async () => {
expect(1).toEqual(1);
});
});
8 changes: 4 additions & 4 deletions examples/src/same-title.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
jest.retryTimes(2);

describe('Test cases with same title', () => {
describe("Test cases with same title", () => {
let j = 0;

test('Test case example', () => {
test("Test case example", () => {
expect(j++).toBe(2);
});

test.skip('Test case example', () => {
test.skip("Test case example", () => {
expect(1).toBe(1);
});

test('Test case example', () => {
test("Test case example", () => {
expect(1).toBe(1);
});
});
4 changes: 2 additions & 2 deletions examples/src/skipped/skipped.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe.skip('skipped block', () => {
it('test inside skipped block', () => {
describe.skip("skipped block", () => {
it("test inside skipped block", () => {
expect(1).toBe(1);
}, 5000);
});
4 changes: 2 additions & 2 deletions examples/src/sum.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sum } from './sum';
import { sum } from "./sum";

test('[failed] adds 1 + 2 to equal 3', () => {
test("[failed] adds 1 + 2 to equal 3", () => {
expect(sum(1, 2)).toBe(4);
});
4 changes: 2 additions & 2 deletions examples/src/sum.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function sum(a, b) {
return a + b;
}
return a + b;
}
6 changes: 3 additions & 3 deletions examples/src/tag.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
describe('Test with @tag', () => {
test('Test A @tagA', () => {
describe("Test with @tag", () => {
test("Test A @tagA", () => {
expect(1).toBe(1);
});

test.skip('Test B @tagB', () => {
test.skip("Test B @tagB", () => {
expect(1).toBe(1);
});
});
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
"scripts": {
"build": "turbo run build",
"dev": "turbo run dev --parallel",
"lint": "turbo run lint",
"format": "prettier --check .",
"format-fix": "prettier --write ."
"lint": "turbo run lint"
},
"devDependencies": {
"eslint-config-custom": "*",
Expand Down
20 changes: 10 additions & 10 deletions packages/cmd/publish.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
#!/usr/bin/env node

const { execSync } = require('child_process');
const fs = require('fs');
const pkg = require('./package.json');
const { Command } = require('commander');
const { execSync } = require("child_process");
const fs = require("fs");
const pkg = require("./package.json");
const { Command } = require("commander");

const program = new Command()
.name('publish')
.option('-t, --tag <alpha | beta | latest>', 'npm dist-tag to publish to');
.name("publish")
.option("-t, --tag <alpha | beta | latest>", "npm dist-tag to publish to");

program.parse(process.argv);
const options = program.opts();

console.log(options);
if (!options.tag) {
console.log('No tag supplied: beta or latest');
console.log("No tag supplied: beta or latest");
process.exit(1);
}
console.log(process.cwd());
// fs.copyFileSync("./CHANGELOG.md", "./CHANGELOG.md");
fs.copyFileSync('../../LICENSE.md', './LICENSE.md');
fs.copyFileSync("../../LICENSE.md", "./LICENSE.md");
execSync(`npm pack --dry-run && npm publish --tag ${options.tag}`, {
cwd: './',
stdio: 'inherit',
cwd: "./",
stdio: "inherit",
});
24 changes: 12 additions & 12 deletions packages/cmd/src/api/cache.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { debug as _debug } from '../debug';
import { makeRequest } from '../http';
import { ClientType } from '../http/client';
import { debug as _debug } from "../debug";
import { makeRequest } from "../http";
import { ClientType } from "../http/client";

const debug = _debug.extend('api');
const debug = _debug.extend("api");

export type CacheRequestParams = {
recordKey: string;
Expand All @@ -26,36 +26,36 @@ export type CacheRetrievalResponse = {

export async function createCache(params: CacheRequestParams) {
try {
debug('Request params: %o', params);
debug("Request params: %o", params);

return makeRequest<CacheCreationResponse, CacheRequestParams>(
ClientType.API,
{
url: 'cache/upload',
method: 'POST',
url: "cache/upload",
method: "POST",
data: params,
}
).then((res) => res.data);
} catch (err) {
debug('Failed to create cache:', err);
debug("Failed to create cache:", err);
throw err;
}
}

export async function retrieveCache(params: CacheRequestParams) {
try {
debug('Request params: %o', params);
debug("Request params: %o", params);

return makeRequest<CacheRetrievalResponse, CacheRequestParams>(
ClientType.API,
{
url: 'cache/download',
method: 'POST',
url: "cache/download",
method: "POST",
data: params,
}
).then((res) => res.data);
} catch (err) {
debug('Failed to retrieve cache:', err);
debug("Failed to retrieve cache:", err);
throw err;
}
}
Loading

0 comments on commit d809072

Please sign in to comment.