resora 0.1.3 → 0.1.5
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/bin/index.mjs +1 -1
- package/package.json +2 -2
package/bin/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
import e,{dirname as t,join as n}from"path";import{existsSync as r,mkdirSync as i,readFileSync as a,rmSync as o,writeFileSync as s}from"fs";import{createRequire as c}from"module";import{fileURLToPath as l}from"url";import{Command as u,Kernel as d}from"@h3ravel/musket";const f=e.dirname(l(import.meta.url));let p=e.resolve(f,`../node_modules/resora/stubs`);r(p)||(p=e.resolve(f,`../stubs`));const m=(e={})=>Object.assign({resourcesDir:`src/resources`,stubsDir:p,stubs:{resource:`resource.stub`,collection:`resource.collection.stub`}},e,{stubs:Object.assign({resource:`resource.stub`,collection:`resource.collection.stub`},e.stubs||{})});var h=class{command;config={};constructor(e={}){this.config=m(e);let t=c(import.meta.url),i=[n(process.cwd(),`resora.config.ts`),n(process.cwd(),`resora.config.js`),n(process.cwd(),`resora.config.cjs`)];for(let e of i)if(r(e))try{let{default:n}=t(e);Object.assign(this.config,m(n));break}catch(t){console.error(`Error loading config file at ${e}:`,t)}}ensureDirectory(e){let n=t(e);r(n)||i(n,{recursive:!0})}generateFile(e,t,n,i){r(t)&&!i?.force?(this.command.error(`Error: ${t} already exists.`),process.exit(1)):r(t)&&i?.force&&o(t);let c=a(e,`utf-8`);for(let[e,t]of Object.entries(n))c=c.replace(RegExp(`{{${e}}}`,`g`),t);return this.ensureDirectory(t),s(t,c),t}makeResource(e,t){let i=e;t?.collection&&!e.endsWith(`Collection`)&&!e.endsWith(`Resource`)?i+=`Collection`:!t?.collection&&!e.endsWith(`Resource`)&&!e.endsWith(`Collection`)&&(i+=`Resource`);let a=`${i}.ts`,o=n(this.config.resourcesDir,a),s=n(this.config.stubsDir,t?.collection||e.endsWith(`Collection`)?this.config.stubs.collection:this.config.stubs.resource);r(s)||(this.command.error(`Error: Stub file ${s} not found.`),process.exit(1));let c=i.replace(/(Resource|Collection)$/,``)+`Resource`,l=`/**
|
|
3
3
|
* The resource that this collection collects.
|
|
4
4
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resora",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "A structured API response layer for Node.js and TypeScript with automatic JSON responses, collection support, and pagination handling.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"json",
|
|
15
15
|
"response"
|
|
16
16
|
],
|
|
17
|
-
"homepage": "https://github.
|
|
17
|
+
"homepage": "https://toneflix.github.io/resora",
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/toneflix/resora/issues"
|
|
20
20
|
},
|