diff --git a/.gitignore b/.gitignore index e70adb6..db4c6d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -# npmize dist -.npmize node_modules \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 252e1f9..b277f30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "npmize", - "version": "1.0.14", + "version": "1.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "npmize", - "version": "1.0.14", + "version": "1.1.0", "license": "ISC", "dependencies": { "@babel/parser": "^7.25.6", diff --git a/package.json b/package.json index 6215814..631b499 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "npmize", + "version": "1.1.1", "description": "Let's create an npm package without worrying about anything.", - "version": "1.1.0", "bin": "./dist/index.js", "scripts": { "dev": "tsc -w", @@ -9,7 +9,6 @@ "tsc": "tsc --noEmit --watch", "lab": "run ./src/__lab__/index.ts" }, - "type": "commonjs", "dependencies": { "@babel/parser": "^7.25.6", "ansi-colors": "^4.1.3", @@ -23,19 +22,27 @@ }, "keywords": [ "npm", + "npmize", "npm-tool", "npm-build", "build-tool", - "npm-build-tool" + "npm-build-tool", + "npm-package", + "npm-package-tool", + "npm-package-maker", + "npm-package-builder", + "npm-package-creator", + "npm-package-generator" ], "license": "ISC", + "type": "commonjs", "author": "https://github.com/NazmusSayad", + "homepage": "https://github.com/NazmusSayad/npmize#readme", "repository": { "type": "git", "url": "git+https://github.com/NazmusSayad/npmize.git" }, "bugs": { "url": "https://github.com/NazmusSayad/npmize/issues" - }, - "homepage": "https://github.com/NazmusSayad/npmize#readme" + } } diff --git a/src/__lab__/another.ts b/src/__lab__/another.ts index 11777c6..e69de29 100644 --- a/src/__lab__/another.ts +++ b/src/__lab__/another.ts @@ -1,3 +0,0 @@ -import rype from '../../../rype/dist/index.mjs' - -console.log(rype) \ No newline at end of file diff --git a/src/__lab__/index.ts b/src/__lab__/index.ts index 8c16257..80b5817 100644 --- a/src/__lab__/index.ts +++ b/src/__lab__/index.ts @@ -1,8 +1,9 @@ console.clear() -const TEST_TARGET = '../rype' +const TEST_TARGET = '../npmize-test' import { app } from '../app' import '../main' // app.start(['init', TEST_TARGET]) // app.start(['dev', TEST_TARGET]) -app.start(['build', TEST_TARGET]) +// app.start(['build', TEST_TARGET]) +app.start(['-v']) diff --git a/src/app.ts b/src/app.ts index a2e0170..7493944 100644 --- a/src/app.ts +++ b/src/app.ts @@ -20,29 +20,33 @@ export const init = app.create('init', { arguments: [ { name: 'name', - type: NoArg.string() - .description('Name of the package') - .ask("What's the name of the package?") - .default('.'), + description: 'Name of the package', + type: NoArg.string().default('.').ask("What's the name of the package?"), }, ], flags: { - pkg: NoArg.boolean().default(true).description("Write 'package.json'"), - install: NoArg.boolean().default(true).description('Install TypeScript'), + pkg: NoArg.boolean() + .default(true) + .description('Make package.json with needed fields'), tsconfig: NoArg.boolean() .default(true) .description('Write "tsconfig.json"'), - demo: NoArg.boolean().default(true).description('Write a sample file'), workflow: NoArg.boolean() .default(true) .description('Write a workflow file'), - + install: NoArg.boolean() + .default(true) + .description('Install needed npm packages'), + sample: NoArg.boolean() + .default(true) + .description('Write a sample file ./src/index.ts'), ignore: NoArg.boolean() .default(true) .description("Write '.gitignore' and '.npmignore'"), - npmignore: NoArg.boolean().default(true).description("Write '.npmignore'"), - gitignore: NoArg.boolean().default(true).description("Write '.gitignore'"), + + npmignore: NoArg.boolean().default(true).description('Write .npmignore'), + gitignore: NoArg.boolean().default(true).description('Write .gitignore'), }, }) @@ -50,6 +54,7 @@ const devAndBuild = NoArg.defineConfig({ optionalArguments: [ { name: 'root', + description: 'Root directory of the package', type: NoArg.string().description('Root directory'), }, ], @@ -57,7 +62,7 @@ const devAndBuild = NoArg.defineConfig({ flags: { module: NoArg.string('cjs', 'mjs') .aliases('m') - .description("Output module's type"), + .description('Output module type .cjs or .mjs'), node: NoArg.boolean() .aliases('n') @@ -65,8 +70,6 @@ const devAndBuild = NoArg.defineConfig({ .description('Enable __dirname and __filename in ES modules'), }, - trailingArguments: '--tsc', - notes: [ `Arguments after "${ansiColors.yellow( '--tsc' @@ -76,14 +79,18 @@ const devAndBuild = NoArg.defineConfig({ .map((flag) => ansiColors.yellow(flag)) .join(', ') + ' and their aliases are ignored.', ], + + trailingArguments: '--tsc', + customRenderHelp: { helpUsageTrailingArgsLabel: '[TypeScript Args]' }, }) export const dev = app.create('dev', { ...devAndBuild, - description: 'Start a development', + description: 'Start the development compiler', flags: { ...devAndBuild.flags, focus: NoArg.string('cjs', 'mjs') + .aliases('f') .default('mjs') .description( 'Focus the typescript compilation process of a specific module' diff --git a/src/main.ts b/src/main.ts index d8ecabc..3ff1232 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,11 +13,11 @@ app.app.on((_, flags) => { } else app.app.renderHelp() }) -app.init.on(([nameArg = '.'], flags) => { - const root = path.resolve(nameArg) +app.init.on(([name = '.'], flags) => { + const root = path.resolve(name) init(root, { - writeSample: flags.demo, + writeSample: flags.sample, writePackageJSON: flags.pkg, installPackages: flags.install, writeGitIgnore: flags.ignore && flags.gitignore, @@ -27,8 +27,8 @@ app.init.on(([nameArg = '.'], flags) => { }) }) -app.dev.on(([rootArg = '.', railingArgs], options) => { - const rootPath = path.resolve(rootArg) +app.dev.on(([root = '.', railingArgs], options) => { + const rootPath = path.resolve(root) const tsConfig = readTSConfig(rootPath) if (!tsConfig) { @@ -52,8 +52,8 @@ app.dev.on(([rootArg = '.', railingArgs], options) => { }) }) -app.build.on(([rootArg = '.', railingArgs], options) => { - const rootPath = path.resolve(rootArg) +app.build.on(([root = '.', railingArgs], options) => { + const rootPath = path.resolve(root) const tsConfig = readTSConfig(rootPath) if (!tsConfig) { diff --git a/src/utils/index.ts b/src/utils/index.ts index af9e9b8..0cc430c 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -5,7 +5,7 @@ import packageJSON from '../scripts/packageJSON' import config from '../config' export function getVersion() { - return packageJSON.read(path.join(__dirname, '../')).version + return 'v' + packageJSON.read(path.join(__dirname, '../../')).version } export function getNodeModulesTempDir(baseDir: string, suffix: string) {