express-todo 1.1.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/LICENSE +21 -0
- package/bin/cli.js +12 -0
- package/bin/core/getLatestVersion.js +13 -0
- package/bin/core/loadRunner.js +9 -0
- package/bin/v1/commands/exportCommands/express.js +9 -0
- package/bin/v1/commands/express/steps/announce.js +3 -0
- package/bin/v1/commands/express/steps/createProject.js +7 -0
- package/bin/v1/commands/express/steps/locateDestination.js +5 -0
- package/bin/v1/commands/express/steps/locateSource.js +16 -0
- package/bin/v1/commands/express/template/v7/.env +9 -0
- package/bin/v1/commands/express/template/v7/.env.local +7 -0
- package/bin/v1/commands/express/template/v7/.vscode/launch.json +12 -0
- package/bin/v1/commands/express/template/v7/Config/Schemas/BillsTable.json +165 -0
- package/bin/v1/commands/express/template/v7/Config/Schemas/ItemsTable.json +200 -0
- package/bin/v1/commands/express/template/v7/Config/Schemas/LedgerNames.json +60 -0
- package/bin/v1/commands/express/template/v7/Config/Schemas/StockItems.json +50 -0
- package/bin/v1/commands/express/template/v7/Config/api.json +8 -0
- package/bin/v1/commands/express/template/v7/Config/schema.json +8 -0
- package/bin/v1/commands/express/template/v7/Config/ui.json +8 -0
- package/bin/v1/commands/express/template/v7/Public/index.html +129 -0
- package/bin/v1/commands/express/template/v7/app.js +19 -0
- package/bin/v1/commands/express/template/v7/config.json +4 -0
- package/bin/v1/commands/express/template/v7/configLoader.js +6 -0
- package/bin/v1/commands/express/template/v7/package-lock.json +834 -0
- package/bin/v1/commands/express/template/v7/package.json +21 -0
- package/bin/v1/commands/express/template/v7/port.js +6 -0
- package/bin/v1/commands/express/template/v7/routes.js +5 -0
- package/bin/v1/commands/express/template/v7/server.js +13 -0
- package/bin/v1/commands/express.js +19 -0
- package/bin/v1/core/parseInput.js +10 -0
- package/bin/v1/core/resolveCommand.js +10 -0
- package/bin/v1/core/resolveFolderName.js +17 -0
- package/bin/v1/core/showUsage.js +45 -0
- package/bin/v1/start.js +22 -0
- package/index.js +8 -0
- package/package.json +35 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "KeshavSoft",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "app.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"start": "node --env-file=.env app.js"
|
|
10
|
+
},
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@keshavsoft/kschema": "^1.17.12",
|
|
15
|
+
"body-parser": "^2.2.0",
|
|
16
|
+
"express": "^5.1.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@keshavsoft/kschema-api-gen": "^1.6.4"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import http from "http";
|
|
2
|
+
import normalizePort from "./port.js";
|
|
3
|
+
|
|
4
|
+
export default function startServer(app) {
|
|
5
|
+
const port = normalizePort(process.env.PORT || 3000);
|
|
6
|
+
const server = http.createServer(app);
|
|
7
|
+
|
|
8
|
+
server.listen(port, () => {
|
|
9
|
+
console.log(`http://localhost:${port}`);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
return { port }; // 👈 add this
|
|
13
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { locateSource } from "./express/steps/locateSource.js";
|
|
2
|
+
import { locateDestination } from "./express/steps/locateDestination.js";
|
|
3
|
+
import { createProject } from "./express/steps/createProject.js";
|
|
4
|
+
import { announce } from "./express/steps/announce.js";
|
|
5
|
+
|
|
6
|
+
import resolveFolderName from "../core/resolveFolderName.js";
|
|
7
|
+
|
|
8
|
+
export default ({ folderName =""}) => {
|
|
9
|
+
const resolvedFolderName = resolveFolderName({
|
|
10
|
+
name: folderName
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const source = locateSource();
|
|
14
|
+
const destination = locateDestination({ inResolvedFolderName: resolvedFolderName });
|
|
15
|
+
|
|
16
|
+
createProject({ source, destination });
|
|
17
|
+
|
|
18
|
+
announce({ inResolvedFolderName: resolvedFolderName });
|
|
19
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
export default function resolveFolderName({ name, inType = "basic" }) {
|
|
4
|
+
const defaultFolerName = `keshavsoft-${inType}-${Date.now()}`;
|
|
5
|
+
|
|
6
|
+
// case 1: force new → timestamp
|
|
7
|
+
if (name === null) {
|
|
8
|
+
name = defaultFolerName;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// case 2: user provided → strict
|
|
12
|
+
if (fs.existsSync(name)) {
|
|
13
|
+
throw new Error(`Folder already exists: ${name}`);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return name;
|
|
17
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
KSchema CLI – Entry Flow
|
|
3
|
+
|
|
4
|
+
1. Read user input from terminal (parseInput)
|
|
5
|
+
2. If no command → show usage (first-time user safety)
|
|
6
|
+
3. If help flags → show usage (quick guidance)
|
|
7
|
+
4. Resolve command dynamically (no hardcoding logic)
|
|
8
|
+
5. If command not found → inform + guide back to usage
|
|
9
|
+
6. Execute command with parsed input
|
|
10
|
+
|
|
11
|
+
Goal:
|
|
12
|
+
- Zero confusion for user
|
|
13
|
+
- Single source of truth (showUsage)
|
|
14
|
+
- Easy to extend (just add commands, no core changes)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export default function showUsage(version) {
|
|
18
|
+
const g = "\x1b[32m";
|
|
19
|
+
const y = "\x1b[33m";
|
|
20
|
+
const c = "\x1b[36m";
|
|
21
|
+
const gray = "\x1b[90m";
|
|
22
|
+
const r = "\x1b[0m";
|
|
23
|
+
|
|
24
|
+
console.log(`
|
|
25
|
+
${c}🚀 KSchema CLI v${version}${r}
|
|
26
|
+
|
|
27
|
+
${y}Usage:${r}
|
|
28
|
+
${g}npx @keshavsoft/kschema-cli${r} <command> [options]
|
|
29
|
+
|
|
30
|
+
${y}Commands:${r}
|
|
31
|
+
${g}init${r} Initialize a new schema setup
|
|
32
|
+
${g}express${r} Initialize a new express project
|
|
33
|
+
${g}tally${r} Initialize a new tally project
|
|
34
|
+
${g}generate-samples${r} Generate sample schema files
|
|
35
|
+
${g}accounts${r} Initialize a new express project for simple accounting
|
|
36
|
+
|
|
37
|
+
${y}Examples:${r}
|
|
38
|
+
${gray}npx @keshavsoft/kschema-cli init${r}
|
|
39
|
+
${gray}npx @keshavsoft/kschema-cli test users${r}
|
|
40
|
+
${gray}npx @keshavsoft/kschema-cli accounts${r}
|
|
41
|
+
|
|
42
|
+
${y}Tip:${r}
|
|
43
|
+
${gray}npm i -g @keshavsoft/kschema-cli${r}
|
|
44
|
+
`);
|
|
45
|
+
}
|
package/bin/v1/start.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import parseInput from "./core/parseInput.js";
|
|
2
|
+
import resolveCommand from "./core/resolveCommand.js";
|
|
3
|
+
import showUsage from './core/showUsage.js';
|
|
4
|
+
import pkg from '../../package.json' with { type: 'json' };
|
|
5
|
+
|
|
6
|
+
const version = pkg.version;
|
|
7
|
+
|
|
8
|
+
const run = async () => {
|
|
9
|
+
const input = parseInput();
|
|
10
|
+
|
|
11
|
+
if (!input.cmd) return showUsage(version);
|
|
12
|
+
|
|
13
|
+
if (input.cmd === "--help" || input.cmd === "-h" || input.cmd === "help") return showUsage(version);
|
|
14
|
+
|
|
15
|
+
const command = resolveCommand(input.cmd);
|
|
16
|
+
|
|
17
|
+
if (!command) return (console.log(`Unknown command: ${input.cmd}\n`), showUsage(version));
|
|
18
|
+
|
|
19
|
+
await command(input);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default run;
|
package/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import getLatestVersion from "./bin/core/getLatestVersion.js";
|
|
2
|
+
|
|
3
|
+
const load = async (cmd) => {
|
|
4
|
+
const v = getLatestVersion();
|
|
5
|
+
return (await import(`./bin/${v}/commands/exportCommands/${cmd}.js`)).default;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const express = async (...a) => (await load("express"))(...a);
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "express-todo",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "CLI to scaffold projects using templates",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"scaffold",
|
|
8
|
+
"templates",
|
|
9
|
+
"node",
|
|
10
|
+
"project-generator"
|
|
11
|
+
],
|
|
12
|
+
"dependencies": {
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./index.js"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"express-todo": "./bin/cli.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin/",
|
|
23
|
+
"index.js",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"homepage": "https://cli.keshavsoft.com",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/keshavsoft/express-todo"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/keshavsoft/express-todo/issues"
|
|
34
|
+
}
|
|
35
|
+
}
|