Skip to content

Commit

Permalink
feat: fixup build output
Browse files Browse the repository at this point in the history
  • Loading branch information
linbudu599 committed Apr 27, 2024
1 parent a77663e commit b345104
Show file tree
Hide file tree
Showing 27 changed files with 463 additions and 153 deletions.
34 changes: 19 additions & 15 deletions packages/mustard-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@
"url": "git+https://github.com/LinbuduLab/Mustard.git",
"directory": "packages/mustard-cli"
},
"type": "module",
"exports": {
".": {
"types": "./dist/Exports/index.d.ts",
"import": "./dist/Exports/index.js",
"require": "./dist/Exports/index.js"
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/cjs/index.js"
},
"./decorator": {
"types": "./dist/Exports/Decorators.d.ts",
"import": "./dist/Exports/Decorators.js",
"require": "./dist/Exports/Decorators.js"
"require": "./dist/cjs/Exports/Decorators.js"
},
"./cli": {
"types": "./dist/Exports/ComanndLine.d.ts",
"import": "./dist/Exports/ComanndLine.js",
"require": "./dist/Exports/ComanndLine.js"
"require": "./dist/cjs/Exports/ComanndLine.js"
},
"./validator": {
"types": "./dist/Exports/Validator.d.ts",
"import": "./dist/Exports/Validator.js",
"require": "./dist/Exports/Validator.js"
"require": "./dist/cjs/Exports/Validator.js"
}
},
"main": "./dist/Exports/index.js",
"types": "./dist/Exports/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"decorator": [
Expand All @@ -45,8 +45,12 @@
]
}
},
"type": "module",
"scripts": {
"build": "tsc --declarationMap false",
"build": "rm -rf dist && pnpm run build && pnpm run build:cjs",
"build:cjs": "tsc --declarationMap false --module CommonJs --moduleResolution node --outDir dist/cjs --declaration false",
"build": "tsc --declarationMap false ",
"check": "tsc --noEmit",
"dev": "tsc --watch",
"local": "nodemon index.ts run sync --dry",
"prepublishOnly": "pnpm run pub:check && pnpm run build",
Expand All @@ -62,7 +66,7 @@
"NODE_ENV": "development"
},
"execMap": {
"ts": "ts-node-esm"
"ts": "ts-node"
},
"ext": "ts,json",
"ignore": [
Expand All @@ -77,15 +81,15 @@
]
},
"dependencies": {
"chalk": "^5.3.0",
"debug": "^4.3.4",
"fastest-levenshtein": "^1.0.16",
"find-up": "^7.0.0",
"lodash.groupby": "^4.6.0",
"lodash.uniqby": "^4.7.0",
"mri": "^1.2.0",
"picocolors": "^1.0.0",
"yargs-parser": "^21.1.1",
"zod": "^3.23.3"
"zod": "^3.23.4"
},
"devDependencies": {
"@types/debug": "^4.1.12",
Expand All @@ -94,7 +98,7 @@
"@types/node": "^20.12.7",
"@types/tmp": "^0.2.6",
"@types/yargs-parser": "^21.0.3",
"@vitest/coverage-v8": "^1.5.0",
"@vitest/coverage-v8": "^1.5.2",
"cross-env": "^7.0.3",
"execa": "^8.0.1",
"lodash": "^4.17.21",
Expand All @@ -103,7 +107,7 @@
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.4.5",
"vitest": "^1.5.0"
"vitest": "^1.5.2"
},
"peerDependencies": {
"typescript": ">=5.0.0"
Expand Down
6 changes: 4 additions & 2 deletions packages/mustard-cli/source/Commands/BuiltInCommands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from "chalk";
import picocolors from "picocolors";

import { UsageInfoGenerator } from "../Components/UsageGenerator";
import { MustardConstanst } from "../Components/Constants";
Expand Down Expand Up @@ -81,7 +81,9 @@ export class BuiltInCommands {

if (!controller) return;

console.log(`V ${chalk.bold(BuiltInCommands.useController(controller))}`);
console.log(
`V ${picocolors.bold(BuiltInCommands.useController(controller))}`
);

exit && process.exit(0);
}
Expand Down
10 changes: 5 additions & 5 deletions packages/mustard-cli/source/Errors/ValidationError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from "zod";
import chalk from "chalk";
import picocolors from "picocolors";

import type { ZodInvalidTypeIssue } from "zod";

Expand All @@ -16,8 +16,8 @@ export class ValidationError extends Error {
}

get message(): string {
return chalk.yellow(
`Invalid input for option ${chalk.bold(this.invalidOptionName)}`
return picocolors.yellow(
`Invalid input for option ${picocolors.bold(this.invalidOptionName)}`
);
}

Expand All @@ -27,9 +27,9 @@ export class ValidationError extends Error {
const { expected, received, message } = <ZodInvalidTypeIssue>issue;

if (expected && received) {
return `Invalid input for argument '${argName}', expected: ${chalk.green(
return `Invalid input for argument '${argName}', expected: ${picocolors.green(
expected
)}, received: ${chalk.yellow(received)}`;
)}, received: ${picocolors.yellow(received)}`;
} else {
return message ?? `Invalid input for argument '${argName}`;
}
Expand Down
19 changes: 0 additions & 19 deletions packages/mustard-cli/source/Exports/index.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/mustard-cli/source/__tests__/Fixtures/TestHelper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export class TestHelper {
public static IntegrationExecutor = "ts-node-esm --transpile-only";
public static IntegrationExecutor =
"ts-node-esm --esm --transpileOnly --experimentalSpecifierResolution=explicit";
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory, Context, MustardUtils } from "../../Exports";
import { MustardFactory, Context, MustardUtils } from "../..";
import {
Command,
RootCommand,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import { RootCommand, App } from "../../../Exports/Decorators";
import { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";
import type { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";

@RootCommand()
class RootCommandHandle implements CommandStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MustardFactory } from "../../../Exports";
import { MustardFactory } from "../../..";
import { RootCommand, App } from "../../../Exports/Decorators";
import { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";
import type { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";

@RootCommand()
class RootCommandHandle implements CommandStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import { RootCommand, App, Command, Option } from "../../../Exports/Decorators";
import { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";
import type { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";

@Command("update", "execute update command")
class UpdateCommandHandle implements CommandStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports";
import { MustardFactory } from "../../../";
import {
Command,
RootCommand,
Expand All @@ -8,7 +8,7 @@ import {
Input,
Options,
} from "../../../Exports/Decorators";
import { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";
import type { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";

@RootCommand()
class RootCommandHandle implements CommandStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import {
RootCommand,
Option,
App,
Input,
Options,
} from "../../../Exports/Decorators";
import { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";
import type { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";

@RootCommand()
class RootCommandHandle1 implements CommandStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import {
Command,
RootCommand,
Expand All @@ -8,7 +8,7 @@ import {
Input,
Options,
} from "../../../Exports/Decorators";
import { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";
import type { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";

@RootCommand()
class RootCommandHandle implements CommandStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import {
RootCommand,
Option,
Restrict,
App,
} from "../../../Exports/Decorators";
import { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";
import type { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";

const restrictArray = ["foo", "bar", "baz"] as const;

Expand All @@ -21,8 +21,8 @@ enum RestrictEnum {
Baz = "baz",
}

type RestrictArrayType = typeof restrictArray[number];
type RestrictObjectType = typeof restrictObject[keyof typeof restrictObject];
type RestrictArrayType = (typeof restrictArray)[number];
type RestrictObjectType = (typeof restrictObject)[keyof typeof restrictObject];

@RootCommand()
class RootCommandHandle implements CommandStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import {
RootCommand,
Option,
Expand All @@ -7,7 +7,7 @@ import {
Input,
Options,
} from "../../../Exports/Decorators";
import { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";
import type { CommandStruct, MustardApp } from "../../../Exports/ComanndLine";

@RootCommand()
class RootCommandHandle implements CommandStruct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import { App } from "../../../Exports/Decorators";

@App({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import { App } from "../../../Exports/Decorators";

@App({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import {
RootCommand,
Option,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import {
RootCommand,
Option,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import {
RootCommand,
Option,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import {
RootCommand,
Option,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MustardFactory } from "../../../Exports/index";
import { MustardFactory } from "../../../index";
import {
RootCommand,
Option,
Expand Down
19 changes: 19 additions & 0 deletions packages/mustard-cli/source/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MustardUtilsProvider } from "./Components/MustardUtilsProvider";

export * from "./Exports/Decorators";
export * from "./Exports/ComanndLine";
export { Validator } from "./Exports/Validator";
export { MustardFactory } from "./Components/MustardFactory";

export type MustardUtils = Omit<typeof MustardUtilsProvider, "produce">;
export type { Context } from "./Typings/Context.struct";

export type * from "./Typings/Command.struct";
export type * from "./Typings/Configuration.struct";
export type * from "./Typings/Context.struct";
export type * from "./Typings/DIService.struct";
export type * from "./Typings/Factory.struct";
export type * from "./Typings/Option.struct";
export type * from "./Typings/Shared.struct";
export type * from "./Typings/Temp";
export type * from "./Typings/Utils.struct";
9 changes: 5 additions & 4 deletions packages/mustard-cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
},
"compilerOptions": {
"lib": [],
"target": "ES6",
"target": "ES2022",
"module": "ES2022",
"outDir": "dist",
"declaration": true,
"declarationMap": true,
"skipLibCheck": true,
"moduleResolution": "node",
"strictNullChecks": true,
"declaration": true,
"strict": true,
"moduleResolution": "node",
"verbatimModuleSyntax": false,
"noImplicitAny": true,
"declarationMap": true,
"noEmitOnError": true,
"noImplicitReturns": true,
"noUnusedParameters": false,
Expand Down
3 changes: 1 addition & 2 deletions packages/sample/index.mts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import path from "path";
import { createRequire } from "module";

import { MustardFactory } from "mustard-cli";
Expand All @@ -12,8 +13,6 @@ import {
import { Validator } from "mustard-cli/validator";
import type { CommandStruct, MustardApp } from "mustard-cli/cli";

import path from "path";

const require = createRequire(import.meta.url);

@RootCommand()
Expand Down
Loading

0 comments on commit b345104

Please sign in to comment.