@nikhil-qeas/api-core 0.4.1 → 0.4.2
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.2 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.2
|
|
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.
|
|
@@ -57,3 +57,7 @@ Releases are published manually to public npmjs.org; GitHub Actions payment elig
|
|
|
57
57
|
## v0.4.1 consumer fix
|
|
58
58
|
|
|
59
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.
|
|
60
|
+
|
|
61
|
+
## Dependency security in generated projects
|
|
62
|
+
|
|
63
|
+
The v0.4.2 candidate changes the generated Mocha requirement from v11 to v12 and adds `npm run audit:security` plus a GitLab high-severity audit gate. This change is **not a claim that audit findings are resolved**: fresh `npm install`, `npm run check`, `npm run test:ci`, and `npm audit` results must be reviewed before publication. Use `npm audit fix` only after reviewing the dependency changes. The `esbuild` postinstall approval warning is separate from npm audit vulnerabilities.
|
package/bin/qe-api.js
CHANGED
|
@@ -7,7 +7,7 @@ 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.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
|
|
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 -e "require(\'node:fs\').mkdirSync(\'reports/junit\',{recursive:true})" && node --import tsx ./node_modules/mocha/bin/mocha.js --config config/mocha.config.json --reporter xunit --reporter-option output=reports/junit/results.xml',check:'npm run typecheck && npm test', 'audit:security':'npm audit --audit-level=high'},devDependencies:{'@nikhil-qeas/api-core':'^0.4.2','@types/mocha':'^10.0.0','@types/node':'^22.0.0',mocha:'^12.0.0',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',
|
|
@@ -20,7 +20,7 @@ const files={
|
|
|
20
20
|
'src/auth/.gitkeep':'','src/contracts/.gitkeep':'','src/data/.gitkeep':'','src/workflows/.gitkeep':'',
|
|
21
21
|
'tests/fixtures/.gitkeep':'','tests/regression/.gitkeep':'','tests/contract/.gitkeep':'','tests/negative/.gitkeep':'','tests/security/.gitkeep':'','docs/.gitkeep':'','reports/.gitkeep':'',
|
|
22
22
|
'tests/smoke/health.spec.ts':"import assert from 'node:assert/strict';\nimport {createServer} from 'node:http';\nimport {once} from 'node:events';\nimport {ApiClient,expectStatus} from '@nikhil-qeas/api-core';\ndescribe('@smoke local API core',()=>{it('tests an isolated mock server',async()=>{const server=createServer((_q,res)=>{res.setHeader('content-type','application/json');res.end(JSON.stringify({status:'ok'}));});server.listen(0,'127.0.0.1');try{await once(server,'listening');const addr=server.address();if(!addr||typeof addr==='string')throw Error('No port');const client=new ApiClient({baseUrl:'http://127.0.0.1:'+addr.port});const result=await client.request({method:'GET',path:'/health'});expectStatus(result,200);assert.deepEqual(result.body,{status:'ok'});}finally{server.close();}});});\n",
|
|
23
|
-
'.gitlab-ci.yml':"stages: [verify,test]\nimage: node:22-bookworm-slim\nverify:\n stage: verify\n script:\n - npm ci\n - npm run typecheck\nsmoke:\n stage: test\n script:\n - npm ci\n - npm run test:ci\n artifacts:\n when: always\n reports:\n junit: reports/junit/results.xml\n paths: [reports/junit/]\n",
|
|
23
|
+
'.gitlab-ci.yml':"stages: [verify,test]\nimage: node:22-bookworm-slim\nverify:\n stage: verify\n script:\n - npm ci\n - npm run typecheck\n - npm run audit:security\nsmoke:\n stage: test\n script:\n - npm ci\n - npm run test:ci\n artifacts:\n when: always\n reports:\n junit: reports/junit/results.xml\n paths: [reports/junit/]\n",
|
|
24
24
|
'README.md':'# '+name+'\n\nGenerated API automation project using @nikhil-qeas/api-core.\n\nRun npm install and npm run check. Sample smoke test uses a local mock HTTP server, not a banking environment.\n\nDirectories: src/clients, src/auth, src/contracts, src/data, src/workflows, tests/smoke, tests/regression, tests/contract, tests/negative, tests/security, config, reports, docs.\n\nStore credentials in approved environment secrets, not source control.\n'
|
|
25
25
|
};
|
|
26
26
|
for(const [path,data] of Object.entries(files)){const full=join(dest,path);mkdirSync(dirname(full),{recursive:true});writeFileSync(full,data,{flag:'wx'});}
|
package/package.json
CHANGED