Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/di binding 3 0 bundle #66

Merged
merged 21 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
185efad
feat: add shared lib as deps & remove config
rsaz Sep 8, 2024
880d405
feat: add env configuration from shared
rsaz Sep 9, 2024
c395d05
fix: restore shared dependency in package.json
rsaz Oct 28, 2024
124a4ec
feat: migrate from Vitest to Jest for testing framework
rsaz Nov 14, 2024
1bd6436
chore: update package version to 3.0.0-beta.1 and integrate BUNDLE_VE…
rsaz Nov 14, 2024
7255a69
fix: add newline at end of file in infoForm function
rsaz Nov 14, 2024
e759366
feat: update scripts for build process and enhance package.json confi…
rsaz Nov 15, 2024
2447b21
feat: enhance pm install proc with improved command handling and prog…
rsaz Nov 15, 2024
6461e50
fix: improve readability of package manager install command logic
rsaz Nov 15, 2024
aec5d24
feat: refactor string case utilities and update dependencies
rsaz Nov 15, 2024
a95accc
fix: standardize string utility function formatting and improve reada…
rsaz Nov 15, 2024
8fe9df5
feat: update package dependencies and enhance CLI command handling
rsaz Nov 18, 2024
88e7b7c
refactor: streamline package manager install command arguments and im…
rsaz Nov 18, 2024
97c7ee4
fix: update development command to use tsx and adjust template copy path
rsaz Nov 18, 2024
95fd9e6
feat: add alias for CLI command and improve module import syntax
rsaz Nov 18, 2024
8f2ab90
chore: update Node.js engine requirement to version 20.18.0
rsaz Nov 19, 2024
9a29024
feat: add remove provider command and enhance add provider functionality
rsaz Nov 19, 2024
6d99bc3
refactor: remove BaseController inheritance and adjusting method sign…
rsaz Nov 19, 2024
dbb4840
refactor: update app container file references and improve module ext…
rsaz Nov 19, 2024
4f5c54d
fix: update module declaration syntax in add-module-to-container utility
rsaz Nov 19, 2024
fc3f48d
feat: add test dir ESLint & update Jest config for improved testing s…
rsaz Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ module.exports = {
"node_modules/*",
"expressots.config.ts",
"commitlint.config.ts",
"vitest.config.ts",
"jest.config.ts",
".eslintrc.cjs",
"coverage/*",
"scripts/*",
"test/**/*.spec.ts",
],
rules: {
"@typescript-eslint/interface-name-prefix": "off",
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ expressots.config.ts

*.tgz

*.container.ts
app.ts

coverage/
coverage/
.early.coverage
6 changes: 5 additions & 1 deletion expressots.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { ExpressoConfig, Pattern } from "./src/types";
import { ExpressoConfig, Pattern } from "@expressots/shared";

const config: ExpressoConfig = {
sourceRoot: "src",
scaffoldPattern: Pattern.KEBAB_CASE,
opinionated: false,
env: {
development: ".env.development",
production: ".env.production",
},
/* scaffoldSchematics: {
entity: "model",
provider: "adapter",
Expand Down
24 changes: 24 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { JestConfigWithTsJest } from "ts-jest";

const config: JestConfigWithTsJest = {
testEnvironment: "node",
roots: ["<rootDir>/src", "<rootDir>/test"],
testRegex: ".*\\.spec\\.ts$",
testPathIgnorePatterns: ["/node_modules/", "/bin/"],
collectCoverageFrom: ["src/**/*.ts", "!**/*.spec.ts", "src/**/index.ts"],
moduleNameMapper: {
"^@src/(.*)$": "<rootDir>/src/$1",
},
setupFiles: ["reflect-metadata"],
transform: {
"^.+\\.ts$": [
"ts-jest",
{
tsconfig: "tsconfig.json",
// Add any ts-jest specific options here
},
],
},
};

export default config;
37 changes: 18 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "@expressots/cli",
"version": "1.12.0",
"version": "3.0.0-beta.1",
"description": "Expressots CLI - modern, fast, lightweight nodejs web framework (@cli)",
"author": "Richard Zampieri",
"license": "MIT",
"bugs": {
"url": "https://github.com/expressots/expressots-cli/issues"
},
"bin": {
"expressots": "bin/cli.js"
"expressots": "bin/cli.js",
"ex": "bin/cli.js"
},
"engines": {
"node": ">=18.0.0"
"node": ">=20.18.0"
},
"funding": {
"type": "github",
Expand All @@ -34,23 +35,22 @@
"prepare": "husky",
"start:build": "npm run build && npm run start",
"start": "node ./bin/cli.js",
"start:dev": "tsnd ./src/cli.ts",
"build": "npm run clean && tsc -p tsconfig.json && yarn cp:templates && chmod +x ./bin/cli.js",
"cp:templates": "cp -r ./src/generate/templates ./bin/generate/templates",
"clean": "rimraf ./bin",
"start:dev": "tsx ./src/cli.ts",
"build": "npm run clean && tsc -p tsconfig.json && npm run cp:templates && node scripts/chmod.js ./bin/cli.js",
"cp:templates": "node scripts/cp.js ./src/generate/templates ./bin/generate/",
"clean": "node scripts/rm.js bin",
"prepublish": "npm run build && npm pack",
"publish": "npm publish --tag latest",
"format": "prettier --write \"./src/**/*.ts\" --cache",
"lint": "eslint \"./src/**/*.ts\"",
"lint:fix": "eslint \"./src/**/*.ts\" --fix",
"release": "release-it",
"test": "vitest run --reporter default",
"test:watch": "vitest",
"coverage": "vitest run --coverage"
"test": "jest",
"coverage": "jest --coverage",
"test:watch": "jest --watch"
},
"dependencies": {
"@expressots/boost-ts": "1.3.0",
"axios": "^1.7.3",
"axios": "1.7.7",
"chalk-animation": "2.0.3",
"cli-progress": "3.12.0",
"cli-table3": "0.6.5",
Expand All @@ -66,31 +66,30 @@
"@codecov/vite-plugin": "^0.0.1-beta.9",
"@commitlint/cli": "19.2.1",
"@commitlint/config-conventional": "19.1.0",
"@expressots/shared": "0.1.0",
"@release-it/conventional-changelog": "7.0.2",
"@types/chalk-animation": "1.6.1",
"@types/cli-progress": "3.11.0",
"@types/degit": "2.8.3",
"@types/inquirer": "9.0.3",
"@types/jest": "^29.5.14",
"@types/mustache": "4.2.2",
"@types/node": "20.12.7",
"@types/yargs": "17.0.22",
"@typescript-eslint/eslint-plugin": "7.6.0",
"@typescript-eslint/parser": "7.6.0",
"@vitest/coverage-v8": "1.4.0",
"chalk": "4.1.2",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"husky": "9.0.11",
"jest": "^29.7.0",
"prettier": "3.2.5",
"reflect-metadata": "0.2.2",
"release-it": "16.3.0",
"rimraf": "5.0.5",
"shx": "0.3.4",
"ts-node-dev": "2.0.0",
"typescript": "5.2.2",
"vite": "5.2.8",
"vite-tsconfig-paths": "4.3.2",
"vitest": "1.4.0"
"ts-jest": "^29.2.5",
"tsx": "^4.19.2",
"typescript": "5.2.2"
},
"release-it": {
"git": {
Expand Down
23 changes: 23 additions & 0 deletions scripts/chmod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { execSync } = require("child_process");

function makeExecutable(targetFile) {
if (process.platform !== "win32") { // Check if the OS is not Windows
try {
execSync(`chmod +x ${targetFile}`);
console.log(`Made ${targetFile} executable.`);
} catch (error) {
console.error(`Error making ${targetFile} executable:`, error.message);
process.exit(1);
}
} else {
console.log(`Skipping chmod on Windows for ${targetFile}`);
}
}

if (process.argv.length !== 3) {
console.error("Usage: node chmod.js <file>");
process.exit(1);
}

const targetFile = process.argv[2];
makeExecutable(targetFile);
35 changes: 35 additions & 0 deletions scripts/cp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require("fs");
const path = require("path");

function copyRecursiveSync(src, dest) {
const exists = fs.existsSync(src);
const stats = exists && fs.statSync(src);
const isDirectory = exists && stats.isDirectory();

if (isDirectory) {
fs.mkdirSync(dest, { recursive: true });
fs.readdirSync(src).forEach(function (childItemName) {
copyRecursiveSync(
path.join(src, childItemName),
path.join(dest, childItemName),
);
});
} else {
fs.copyFileSync(src, dest);
}
}

if (process.argv.length < 4) {
process.stderr.write(
"Usage: node copy.js <origin1> <origin2> ... <destination>\n",
);
process.exit(1);
}

const destination = process.argv[process.argv.length - 1];

for (let i = 2; i < process.argv.length - 1; i++) {
const origin = process.argv[i];
copyRecursiveSync(origin, path.join(destination, path.basename(origin)));
process.stdout.write(`Copied: ${origin} to ${destination}\n`);
}
24 changes: 24 additions & 0 deletions scripts/rm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const fs = require("fs").promises;

const removeTarget = async (target) => {
try {
const targetExists = await fs.stat(target).catch(() => null);
if (!targetExists) {
process.stdout.write(`Directory '${target}' does not exist.\n`);
return;
}
await fs.rm(target, { recursive: true, force: true });
process.stdout.write(`Removed: ${target}\n`);
} catch (error) {
process.stderr.write(`Error: Unable to remove '${target}'\n`);
process.exit(1);
}
};

if (process.argv.length !== 3) {
process.stderr.write("Usage: node rm.js <dir/file>\n");
process.exit(1);
}

const target = process.argv[2];
removeTarget(target);
40 changes: 0 additions & 40 deletions src/@types/config.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/@types/index.ts

This file was deleted.

9 changes: 8 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ import { generateProject } from "./generate";
import { helpCommand } from "./help/cli";
import { infoProject } from "./info";
import { createProject } from "./new";
import { addProviderCMD } from "./providers";
import { addProviderCMD, removeProviderCMD } from "./providers";
import { createExternalProviderCMD } from "./providers/create/cli";
import { printError } from "./utils/cli-ui";
import { scriptsCommand } from "./scripts";

/**
* The current version of the ExpressoTS Bundle.
* core, adapters, and cli.
*/
export const BUNDLE_VERSION = "3.0.0-beta.1";

stdout.write(`\n${[chalk.bold.green("🐎 Expressots")]}\n\n`);

yargs(hideBin(process.argv))
Expand All @@ -28,6 +34,7 @@ yargs(hideBin(process.argv))
.command(prodCommand)
.command(createExternalProviderCMD())
.command(addProviderCMD())
.command(removeProviderCMD())
.command(generateProject())
.command(scriptsCommand())
.command(infoProject())
Expand Down
7 changes: 0 additions & 7 deletions src/commands/__tests__/project.commands.spec.ts

This file was deleted.

19 changes: 4 additions & 15 deletions src/commands/project.commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,13 @@ function getOutDir(): string {
* @returns The configuration
*/
const opinionatedConfig: Array<string> = [
"--transpile-only",
"--clear",
"-r",
"dotenv/config",
"--watch",
"-r",
"tsconfig-paths/register",
"./src/main.ts",
];

const nonOpinionatedConfig: Array<string> = [
"--transpile-only",
"--clear",
"-r",
"dotenv/config",
"./src/main.ts",
];
const nonOpinionatedConfig: Array<string> = ["--watch", "./src/main.ts"];

/**
* Dev command module
Expand Down Expand Up @@ -191,7 +182,7 @@ export const runCommand = async ({
switch (command) {
case "dev":
execCmd(
"tsnd",
"tsx",
opinionated ? opinionatedConfig : nonOpinionatedConfig,
);
break;
Expand Down Expand Up @@ -219,14 +210,12 @@ export const runCommand = async ({
let config: Array<string> = [];
if (opinionated) {
config = [
"-r",
"dotenv/config",
"-r",
`./${outDir}/register-path.js`,
`./${outDir}/src/main.js`,
];
} else {
config = ["-r", "dotenv/config", `./${outDir}/main.js`];
config = [`./${outDir}/main.js`];
}
clearScreen();
execCmd("node", config);
Expand Down
3 changes: 1 addition & 2 deletions src/generate/templates/nonopinionated/module.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ContainerModule } from "inversify";
import { CreateModule } from "@expressots/core";
import { ContainerModule, CreateModule } from "@expressots/core";

export const {{moduleName}}{{schematic}}: ContainerModule = CreateModule([]);
Loading