diff --git a/README.md b/README.md index baf7b3e..2c069fc 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ This package tries to help you to make npm package without thinking about cjs an - Very very simple. - Very very lightweight. - This supports `typescript`. +- **Compile** to `cjs` and `mjs` without any distraction. - Enables `__dirname` and `__filename` for `mjs`(EsModule). +- Can work with **browser**, **node** everything related to JavaScript. npm package @@ -58,69 +60,23 @@ The interface for command-line usage is fairly simplistic at this stage, as seen npmize [options] ``` -### Example: +## How to use? + +Add the help flag to see what **functionality** are available. ```shell -npmize dev +npmize --help ``` -_This starts typescript watch mode._ - -
- ---- - -
- -## Commands - -| Command | Description | -| ------- | ----------------------------- | -| init | Initilize `package.json` | -| dev | Start `typescript` watch mode | -| build | Build for prod | - -
- -## Command Options - -| Option | Description | -| ------------ | --------------------------------------------------------------- | -| --no-install | Not to install required dependencies automatically | -| --no-ignore | Not to add recommended ignore files to .gitignore \| .npmignore | -| --no-src | Not to create src/index.ts folder when not exists | - -### Command: `init` - -| Option | Description | -| -------- | --------------------- | -| --bin | Also add `bin` field | -| --legacy | Uses `.js` for fields | - -### Command: `dev` & `build` - -You can use almost any typescript cli command here by using `--tsc`. -eg: `--tsc--jsx=react` --> `--jsx react` - -Not allowed list: `--project` `--outDir` `--module` `--watch` and their aliases - -| Option | Description | -| ------------ | --------------------------------------- | -| --module=cjs | This starts dev mode of commonjs module | -| --module=mjs | This starts dev mode of esmodule module | - -
- -### Command: `build` - -| Option | Description | -| -------- | ----------------------------------------------------- | -| --node | This enables `__dirname` and `__filename` in esmodule | -| --legacy | Uses `.js` files and creates package.json with type | +### Example: -
+```shell +npmize init project-name +npmize --help +npmize --help-usage +``` ---- +- _*This makes your project ready*_
diff --git a/package-lock.json b/package-lock.json index 21326aa..9c4f74f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@babel/parser": "^7.20.7", "ansi-colors": "^4.1.3", "lskit": "^1.0.0", - "noarg": "^3.0.6", + "noarg": "^3.0.13", "shelljs": "^0.8.5" }, "bin": { @@ -411,15 +411,6 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "license": "MIT" }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "license": "MIT", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -496,20 +487,6 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "license": "MIT" }, - "node_modules/deasync": { - "version": "0.1.30", - "resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.30.tgz", - "integrity": "sha512-OaAjvEQuQ9tJsKG4oHO9nV1UHTwb2Qc2+fadB0VeVtD0Z9wiG1XPGLJ4W3aLhAoQSYTaLROFRbd5X20Dkzf7MQ==", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "bindings": "^1.5.0", - "node-addon-api": "^1.7.1" - }, - "engines": { - "node": ">=0.11.0" - } - }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -530,12 +507,6 @@ "node": ">=4" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "license": "MIT" - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -673,22 +644,16 @@ } }, "node_modules/noarg": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/noarg/-/noarg-3.0.6.tgz", - "integrity": "sha512-AtT5kWxI+NMfqvSNla/2RKrtJB/lgSlrXWooLW+dTugpbuT/AxIHJvBdU6+DnVgn1cKr15RFkYjAzuQM7mIH5w==", + "version": "3.0.13", + "resolved": "https://registry.npmjs.org/noarg/-/noarg-3.0.13.tgz", + "integrity": "sha512-XkgASDCF7LDUEWbmWtVeN9kJ5Zl7Ci0bESNUeFP0Y4cQRri2VfD0k6GkDogwW3YyYeKmlBB3k1ZkR8Cq7FTcgA==", "dependencies": { "@inquirer/prompts": "^5.3.8", "ansi-colors": "^4.1.3", "cli-table3": "^0.6.5", - "deasync": "^0.1.30" + "utility-types": "^3.11.0" } }, - "node_modules/node-addon-api": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", - "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==", - "license": "MIT" - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -876,6 +841,15 @@ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "license": "MIT" }, + "node_modules/utility-types": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/utility-types/-/utility-types-3.11.0.tgz", + "integrity": "sha512-6Z7Ma2aVEWisaL6TvBCy7P8rm2LQoPv6dJ7ecIaIixHcwfbJ0x7mWdbcwlIM5IGQxPZSFYeqRCqlOOeKoJYMkw==", + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, "node_modules/wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", diff --git a/package.json b/package.json index 17cf30e..c7583e7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "npmize", "description": "Let's create an npm package without worrying about anything.", - "version": "1.0.8", + "version": "1.0.9", "bin": "./dist/index.js", "scripts": { "lab": "nodemon ./src/__lab.ts", @@ -13,7 +13,7 @@ "@babel/parser": "^7.20.7", "ansi-colors": "^4.1.3", "lskit": "^1.0.0", - "noarg": "^3.0.6", + "noarg": "^3.0.13", "shelljs": "^0.8.5" }, "devDependencies": { diff --git a/src/__lab.ts b/src/__lab.ts index a18900b..5127bcc 100644 --- a/src/__lab.ts +++ b/src/__lab.ts @@ -2,6 +2,7 @@ console.clear() import app from './main' -app.start(['init', '../npmize-test']) +app.start(['dev', '-h']) +// app.start(['init', '../npmize-test']) // app.start(['dev', '../npmize-test', '--node']) // app.start(['build', '../npmize-test']) diff --git a/src/main.ts b/src/main.ts index 1531eb7..3de0d48 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,7 +9,6 @@ import { getVersion } from './utils' const app = NoArg.create(config.name, { description: config.description, - flags: { version: t.boolean().aliases('v').description('Show the version'), }, @@ -78,18 +77,16 @@ const devAndBuild = { outDir: t.string().aliases('o').description('Output directory'), - tsc: t - .array(t.string()) - .aliases('t') - .default([]) - .description("TypeScript's options"), - node: t .boolean() .aliases('n') .default(false) .description('Enable __dirname and __filename in ES modules'), }, + + config: { + enableTrailingArgs: true, + }, } app @@ -97,10 +94,11 @@ app description: 'Start a development', ...devAndBuild, }) - .on(([rootArg = '.'], options) => { + .on(([rootArg = '.', railingArgs], options) => { const rootPath = path.resolve(rootArg as string) dev(rootPath, { ...options, + tsc: railingArgs as string[], outDir: options.outDir ? path.join(rootPath, options.outDir) : path.join( @@ -116,10 +114,11 @@ app description: 'Build the package for production', ...devAndBuild, }) - .on(([rootArg = '.'], options) => { + .on(([rootArg = '.', railingArgs], options) => { const rootPath = path.resolve(rootArg as string) build(rootPath, { ...options, + tsc: railingArgs as string[], outDir: options.outDir ? path.join(rootPath, options.outDir) : path.join(