Skip to content

Commit

Permalink
workspace:
Browse files Browse the repository at this point in the history
[UPGRADE] deps: `@produck/eslint-rules`
[FIXED] all tests
  • Loading branch information
lichaozhy committed Nov 23, 2024
1 parent 1af258b commit aa0cb9a
Show file tree
Hide file tree
Showing 17 changed files with 178 additions and 165 deletions.
5 changes: 3 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import ProduckRules from '@produck/eslint-rules';
import * as ProduckEslint from '@produck/eslint-rules';

/** @type {import('eslint').Linter.Config[]} */
export default [
{files: ['**/*.{js,mjs,ts}']},
{languageOptions: { globals: {...globals.browser, ...globals.node} }},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
ProduckRules,
ProduckEslint.config,
ProduckEslint.excludeGitIgnore(import.meta.url),
];
217 changes: 119 additions & 98 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
},
"devDependencies": {
"@eslint/js": "^9.15.0",
"@produck/eslint-rules": "^0.1.2",
"@types/mocha": "^10.0.9",
"@types/node": "^22.9.1",
"@produck/eslint-rules": "^0.2.0",
"@types/mocha": "^10.0.10",
"@types/node": "^22.9.3",
"c8": "^10.1.2",
"eslint": "^9.15.0",
"globals": "^15.12.0",
"lerna": "^8.1.9",
"mocha": "^10.8.2",
"rollup": "^4.27.3",
"rollup": "^4.27.4",
"typescript-eslint": "^8.15.0"
},
"workspaces": [
Expand Down
1 change: 1 addition & 0 deletions packages/duck-log/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"main": "src/index.cjs",
"type": "module",
"exports": {
"types": "./index.d.ts",
"import": "./src/index.mjs",
"require": "./src/index.cjs"
},
Expand Down
1 change: 1 addition & 0 deletions packages/duck-log/test/DuckLog.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import assert from 'node:assert/strict';
import { describe, it } from 'mocha';
import * as Duck from '@produck/duck';

import * as DuckLog from '../src/index.mjs';
Expand Down
2 changes: 2 additions & 0 deletions packages/duck-log/test/Logger.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import assert from 'node:assert/strict';
import { describe, it } from 'mocha';

import * as Logger from '../src/Logger/index.mjs';

describe('DuckLog::Logger', function () {
Expand Down
1 change: 1 addition & 0 deletions packages/duck-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"main": "src/index.cjs",
"type": "module",
"exports": {
"types": "./index.d.ts",
"import": "./src/index.mjs",
"require": "./src/index.cjs"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/duck-runner/test/DuckRunner.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import * as Duck from '@produck/duck';
import { describe, it } from 'mocha';

import * as Duck from '@produck/duck';
import * as DuckRunner from '../src/index.mjs';

describe('DuckRunner', function () {
Expand Down Expand Up @@ -96,7 +97,7 @@ describe('DuckRunner', function () {
})();
}, {
name: 'Error',
message: 'Assembler is NOT ready.',
message: 'Installation not completed.',
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion packages/duck-runner/test/Runner.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import * as Duck from '@produck/duck';
import { describe, it } from 'mocha';

import * as Duck from '@produck/duck';
import * as Runner from '../src/Runner/index.mjs';

const ProductKit = Duck.define({ id: 'foo' })();
Expand Down
2 changes: 2 additions & 0 deletions packages/duck-runner/test/Template/Processes.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import assert from 'node:assert/strict';
import cluster from 'node:cluster';
import { describe, it, after } from 'mocha';

import * as Duck from '@produck/duck';
import * as DuckRunner from '../../src/index.mjs';

Expand Down
2 changes: 2 additions & 0 deletions packages/duck-runner/test/Template/Solo.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import assert from 'node:assert/strict';
import { describe, it } from 'mocha';

import * as Duck from '@produck/duck';
import * as DuckRunner from '../../src/index.mjs';

Expand Down
1 change: 1 addition & 0 deletions packages/duck-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"main": "src/index.cjs",
"type": "module",
"exports": {
"types": "./index.d.ts",
"import": "./src/index.mjs",
"require": "./src/index.cjs"
},
Expand Down
65 changes: 33 additions & 32 deletions packages/duck-web/test/DuckWeb.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import http from 'node:http';
import supertest from 'supertest';
import { describe, it } from 'mocha';

import * as Duck from '@produck/duck';

import * as DuckWeb from '../src/index.mjs';
Expand Down Expand Up @@ -81,8 +82,8 @@ describe('DuckWeb', function () {
});
})();
}, {
name: 'Error',
message: 'The `.provider` MUST return a function as `Application`.',
name: 'TypeError',
message: 'Invalid ".provider()=>", one "function" expected.',
});
});
});
Expand Down Expand Up @@ -148,8 +149,8 @@ describe('DuckWeb', function () {

Kit.Web.Application('Foo');
}, {
name: 'Error',
message: 'Bad Application(Foo), one "(req, res) => any" expected.',
name: 'TypeError',
message: 'Invalid "Application(Foo)=>", one "(req, res) => any" expected.',
});

});
Expand All @@ -166,28 +167,27 @@ describe('DuckWeb', function () {

const listener = Kit.Web.App('Default');
const server = http.createServer(listener).listen(8080, '127.0.0.2');
const client = supertest('http://127.0.0.2:8080');

await client
.get('/')
.expect('Content-Type', 'application/json')
.expect(200)
.expect(res => {
assert.deepEqual(res.body, {
meta: {
id: 'foo',
name: 'Default Product Name',
version: '0.0.0',
description: 'No descrition',
},
components: [{
id: 'org.produck.duck.web',
name: 'DuckWeb',
version: res.body.components[0].version,
description: 'For creating and managing multiple application providers.',
}],
});
});
const response = await fetch('http://127.0.0.2:8080/');

assert.equal(response.headers.get('Content-Type'), 'application/json');
assert.equal(response.status, 200);

const json = await response.json();

assert.deepEqual(json, {
meta: {
id: 'foo',
name: 'Default Product Name',
version: '0.0.0',
description: 'No descrition',
},
components: [{
id: 'org.produck.duck.web',
name: 'DuckWeb',
version: json.components[0].version,
description: 'For creating and managing multiple application providers.',
}],
});

server.close();
});
Expand All @@ -207,12 +207,13 @@ describe('DuckWeb', function () {

const listener = Kit.Web.App('Redirect');
const server = http.createServer(listener).listen(8080, '127.0.0.2');
const client = supertest('http://127.0.0.2:8080');

await client
.get('/')
.expect(302)
.expect('Location', 'https://127.0.0.2:8080/');
const response = await fetch('http://127.0.0.2:8080/', {
redirect: 'manual',
});

assert.equal(response.status, 302);
assert.equal(response.headers.get('Location'), 'https://127.0.0.2:8080/');

server.close();
});
Expand Down
3 changes: 2 additions & 1 deletion packages/duck-workspace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"main": "src/index.cjs",
"type": "module",
"exports": {
"types": "./index.d.ts",
"import": "./src/index.mjs",
"require": "./src/index.cjs"
},
Expand Down Expand Up @@ -38,6 +39,6 @@
"@produck/idiom": "^0.3.2",
"@produck/mold": "^0.3.1",
"@produck/ow": "^0.1.2",
"@produck/workspace": "^0.2.6"
"@produck/workspace": "^0.2.7"
}
}
1 change: 1 addition & 0 deletions packages/duck-workspace/test/DuckWorkspace.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as assert from 'node:assert/strict';
import path from 'node:path';
import { describe, it } from 'mocha';

import * as Duck from '@produck/duck';
import * as DuckWorkspace from '../src/index.mjs';
Expand Down
2 changes: 1 addition & 1 deletion packages/duck/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"url": "https://github.com/produck/duck/issues"
},
"dependencies": {
"@produck/compose": "^0.1.8",
"@produck/compose": "^0.1.9",
"@produck/idiom": "^0.3.2",
"@produck/kit": "^0.1.9",
"@produck/mold": "^0.3.1",
Expand Down
24 changes: 0 additions & 24 deletions packages/duck/test/Duck.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -167,29 +167,5 @@ describe('Duck', function () {
});
});
});

describe('Kit::ReadyTo()', function () {
it('should throw if bad fn.', function () {
assert.throws(() => {
Duck.define({ id: 'org.example.test' }, Kit => {
Kit.ReadyTo();
})();
}, {
name: 'TypeError',
message: 'Invalid "fn", one "function" expected.',
});
});

it('should throw if bad message.', function () {
assert.throws(() => {
Duck.define({ id: 'org.example.test' }, Kit => {
Kit.ReadyTo(() => {}, 1);
})();
}, {
name: 'TypeError',
message: 'Invalid "message", one "string" expected.',
});
});
});
});
});

0 comments on commit aa0cb9a

Please sign in to comment.