@nikhil-qeas/api-core 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/bin/qe-api.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A reusable TypeScript API test utility library and project initializer. Public n
|
|
|
7
7
|
**Generate a complete new project:**
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npx --yes --package @nikhil-qeas/api-core@0.4.
|
|
10
|
+
npx --yes --package @nikhil-qeas/api-core@0.4.1 qe-api init my-api-project
|
|
11
11
|
cd my-api-project
|
|
12
12
|
npm install
|
|
13
13
|
npm run check
|
|
@@ -18,7 +18,7 @@ This creates a project with TypeScript, Mocha, test folders, client/auth/contrac
|
|
|
18
18
|
**Add utilities to an existing project:**
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
npm install --save-dev @nikhil-qeas/api-core@0.4.
|
|
21
|
+
npm install --save-dev @nikhil-qeas/api-core@0.4.1
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Installing the package does **not** modify your source tree: utilities live under `node_modules`. Run the generator explicitly when you want a new project. The CLI refuses to overwrite an existing directory.
|
|
@@ -53,3 +53,7 @@ This is a public npm distribution. Review package contents and associated docume
|
|
|
53
53
|
## Distribution
|
|
54
54
|
|
|
55
55
|
Releases are published manually to public npmjs.org; GitHub Actions payment eligibility is not needed. See `docs/RELEASE.md` in the source repository for release verification and publication instructions.
|
|
56
|
+
|
|
57
|
+
## v0.4.1 consumer fix
|
|
58
|
+
|
|
59
|
+
The v0.4.0 generator accidentally supplied an ES module `.mjs` file as a JSON Mocha configuration. v0.4.1 generates `config/mocha.config.json` and points all Mocha scripts to that file. Existing v0.4.0 projects should replace the file and script references or regenerate in a fresh directory. The dependency audit must be checked in each generated project before enterprise use.
|
package/bin/qe-api.js
CHANGED
|
@@ -7,13 +7,13 @@ const name=args[1],opt=args.indexOf('--dir');
|
|
|
7
7
|
if(args[0]!=='init'||!name||!/^[a-z][a-z0-9-]{1,62}$/.test(name)||name.endsWith('-')||name.includes('--')||(opt<0&&args.length!==2)||(opt>=0&&(args.length!==4||!args[opt+1]))){console.error('Invalid arguments. Try: qe-api init my-api');process.exit(2);}
|
|
8
8
|
const dest=resolve(opt<0?name:args[opt+1]);
|
|
9
9
|
if(existsSync(dest)){console.error('Target already exists: '+dest);process.exit(1);}
|
|
10
|
-
const packageJson={name,version:'0.1.0',private:true,type:'module',engines:{node:'>=22.12.0'},scripts:{typecheck:'tsc --noEmit',test:'node --import tsx ./node_modules/mocha/bin/mocha.js --config config/mocha.config.
|
|
10
|
+
const packageJson={name,version:'0.1.0',private:true,type:'module',engines:{node:'>=22.12.0'},scripts:{typecheck:'tsc --noEmit',test:'node --import tsx ./node_modules/mocha/bin/mocha.js --config config/mocha.config.json','test:smoke':'node --import tsx ./node_modules/mocha/bin/mocha.js --config config/mocha.config.json --grep "@smoke"','test:ci':'node --import tsx ./node_modules/mocha/bin/mocha.js --config config/mocha.config.json --reporter mocha-junit-reporter --reporter-options mochaFile=reports/junit/results.xml',check:'npm run typecheck && npm test'},devDependencies:{'@nikhil-qeas/api-core':'^0.4.1','@types/mocha':'^10.0.0','@types/node':'^22.0.0',mocha:'^11.0.0','mocha-junit-reporter':'^2.2.1',tsx:'^4.0.0',typescript:'^5.9.3'}};
|
|
11
11
|
const files={
|
|
12
12
|
'package.json':JSON.stringify(packageJson,null,2)+'\n',
|
|
13
13
|
'tsconfig.json':JSON.stringify({compilerOptions:{target:'ES2022',module:'NodeNext',moduleResolution:'NodeNext',strict:true,esModuleInterop:true,types:['node','mocha'],noEmit:true,skipLibCheck:true},include:['src/**/*.ts','tests/**/*.ts']},null,2)+'\n',
|
|
14
14
|
'.gitignore':'node_modules/\nreports/\n.env\n.env.*\n!.env.example\ndist/\n*.tgz\n',
|
|
15
15
|
'.env.example':'QE_ENV=local\nQE_ALLOW_MUTATIONS=false\n# API_BASE_URL=https://test.example.invalid\n',
|
|
16
|
-
'config/mocha.config.
|
|
16
|
+
'config/mocha.config.json':JSON.stringify({extension:['ts'],spec:['tests/**/*.spec.ts'],timeout:30000,recursive:true,reporter:'spec'},null,2)+'\n',
|
|
17
17
|
'config/environments/.gitkeep':'',
|
|
18
18
|
'src/config/environment.ts':"export function targetBaseUrl(): string {\n const value=process.env.API_BASE_URL;\n if(!value)throw new Error('API_BASE_URL is required');\n const u=new URL(value);\n if(!['http:','https:'].includes(u.protocol))throw new Error('HTTP(S) required');\n return value;\n}\n",
|
|
19
19
|
'src/clients/api.ts':"import {ApiClient} from '@nikhil-qeas/api-core';\nimport {targetBaseUrl} from '../config/environment.js';\n/** Add project auth and security approvals before connecting bank endpoints. */\nexport function createApiClient(){return new ApiClient({baseUrl:targetBaseUrl(),timeoutMs:15000,maxSafeRetries:1});}\n",
|
package/package.json
CHANGED