Skip to content

Commit

Permalink
fix: resolve imports manually (#23)
Browse files Browse the repository at this point in the history
* fix: resolve imports manually

* ci: add E2E tests

* ci: fix build

* chore: remove comments

* chore: remove debug

* ci: add typings tests

* chore: standardize typings style
  • Loading branch information
wellwelwel authored Jul 15, 2024
1 parent becb048 commit e1b0ae7
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,5 @@ jobs:
- name: Installing Dependencies
run: npm ci

- name: Building the Lib
run: npm run build -- --noEmit

- name: Running Tests
run: npm run test
11 changes: 10 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,14 @@
"htmlWhitespaceSensitivity": "css",
"endOfLine": "auto",
"embeddedLanguageFormatting": "auto",
"singleAttributePerLine": false
"singleAttributePerLine": false,
"overrides": [
{
"files": ["src/**/*.d.ts"],
"options": {
"singleQuote": false,
"tabWidth": 4
}
}
]
}
15 changes: 14 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,32 @@
"rules": {
"nursery": {
"useTopLevelRegex": "off"
},
"correctness": {
"noNodejsModules": "off"
}
}
}
},
{
"include": ["src/index.ts"],
"include": ["src/index.ts", "src/index.d.ts"],
"linter": {
"rules": {
"style": {
"noDefaultExport": "off"
}
}
}
},
{
"include": ["**/**/*.cjs"],
"linter": {
"rules": {
"suspicious": {
"noRedundantUseStrict": "off"
}
}
}
}
]
}
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@types/node": "^20.14.10",
"@types/x509.js": "^1.0.3",
"poku": "^2.0.0",
"prettier": "^3.3.3",
Expand Down Expand Up @@ -41,9 +42,11 @@
],
"scripts": {
"build": "npx tsc",
"postbuild": "cp src/index.d.ts lib/index.d.ts",
"lint": "npx @biomejs/biome lint && prettier --check .",
"lint:fix": "npx @biomejs/biome lint --write . && prettier --write .",
"pretest": "npm run build",
"test": "poku --parallel ./test",
"test:ci": "npm run lint && npm run build -- --noEmit && npm run test"
"test:ci": "npm run lint && npm run test"
}
}
8 changes: 8 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Profiles } from "./@types/profiles.js";
export declare const proxyBundle: Profiles;
declare const profiles: Profiles;
declare module "aws-ssl-profiles" {
const profiles: Profiles & { proxyBundle: Profiles };
export = profiles;
}
export default profiles;
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import type { Profiles } from './@types/profiles.js';
import { defaults } from './profiles/ca/defaults.js';
import { proxies } from './profiles/ca/proxies.js';

export const proxyBundle: Profiles = {
const proxyBundle: Profiles = {
ca: proxies,
};

const profiles: Profiles = {
ca: [...defaults, ...proxies],
};

export default profiles;
exports.default = profiles;

module.exports = profiles;
module.exports.proxyBundle = proxyBundle;
11 changes: 11 additions & 0 deletions test/e2e/import.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { test, strict } from 'poku';
import awsCaBundle, { proxyBundle } from '../../lib/index.js';

test('Testing import (ESM)', () => {
strict(typeof awsCaBundle?.ca?.length === 'number', 'Default import');
strict(typeof proxyBundle?.ca?.length === 'number', '"proxyBundle" import');
strict(
typeof awsCaBundle.proxyBundle?.ca?.length === 'number',
'"proxyBundle" from default import'
);
});
14 changes: 14 additions & 0 deletions test/e2e/require.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const { test, strict } = require('poku');
const awsCaBundle = require('../../lib/index.js');
const { proxyBundle } = require('../../lib/index.js');

test('Testing require (CJS)', () => {
strict(typeof awsCaBundle?.ca?.length === 'number', 'Default require');
strict(typeof proxyBundle?.ca?.length === 'number', '"proxyBundle" require');
strict(
typeof awsCaBundle.proxyBundle?.ca?.length === 'number',
'"proxyBundle" from default require'
);
});
9 changes: 9 additions & 0 deletions test/e2e/typings.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, strict } from 'poku';
import { readFile } from 'node:fs/promises';

test('Ensure index.d.ts Typings', async () => {
const src = await readFile('./src/index.d.ts', 'utf-8');
const lib = await readFile('./lib/index.d.ts', 'utf-8');

strict.strictEqual(src, lib, '"src" and "lib" should be the same the same');
});
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationDir": "lib",
"outDir": "lib"
"outDir": "lib",
"allowSyntheticDefaultImports": true
}
}

0 comments on commit e1b0ae7

Please sign in to comment.