Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
},
"scripts": {
"prepack": "npm run build",
"build": "npm run compile",
"prebuild": "npm run ci && rimraf ./dist",
"ci": "npm run check-style && npm run check-build",
"check-style": "npm run format:check && npm run lint",
"check-build": "npm run compile -- --noEmit",
"format": "prettier --write \"*.{js,cjs,mjs,ts,cts,mts}\" \"{src,test}/**/*.ts\"",
"build": "npm run compile",
"ci": "npm run style:check && npm run build:check",
"style:check": "npm run format:check && npm run lint:check",
"build:check": "npm run compile -- --noEmit",
"format:check": "prettier --check \"*.{js,cjs,mjs,ts,cts,mts}\" \"{src,test}/**/*.ts\"",
"lint": "eslint \"{src,test}/**/*.{js,ts}\"",
"lint:fix": "npm run lint -- --fix",
"style": "npm run format && npm run lint:fix",
"lint:check": "eslint \"{src,test}/**/*.{js,ts}\"",
"style": "npm run format && npm run lint",
"format": "prettier --write \"*.{js,cjs,mjs,ts,cts,mts}\" \"{src,test}/**/*.ts\"",
"lint": "npm run lint:check -- --fix",
"compile": "tsc -p tsconfig.json",
"prepare": "husky"
},
Expand Down
44 changes: 21 additions & 23 deletions src/utils/args.ts → src/args.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

import { getConfigData } from '../config/get-config-data.js';
import { PACKAGE_VERSION } from '../constants.js';
import { getConfigData } from './config/get-config-data.js';
import { PACKAGE_VERSION } from './constants.js';

const desc = {
runWith(packageManager: string): string {
Expand All @@ -16,22 +16,20 @@ const group = {
config: 'Config Options:',
};

const options = [
'npm',
'pnpm',
'yarn',
'bun',
'select',
'first',
'default',
'which',
'rename',
] as const;

type Option = (typeof options)[number];
enum Option {
Npm = 'npm',
Pnpm = 'pnpm',
Yarn = 'yarn',
Bun = 'bun',
Select = 'select',
First = 'first',
Default = 'default',
Which = 'which',
Rename = 'rename',
}

function noConflict(itself: Option, ...other: Option[]): Option[] {
return options.filter(
return Object.values(Option).filter(
(option) => option !== itself && !other.includes(option),
);
}
Expand All @@ -45,28 +43,28 @@ const parsed = yargs(hideBin(process.argv))
description: desc.runWith('npm'),
alias: 'n',
group: group.script,
conflicts: noConflict('npm', 'select'),
conflicts: noConflict(Option.Npm, Option.Select),
})
.option('pnpm', {
type: 'boolean',
description: desc.runWith('pnpm'),
alias: 'p',
group: group.script,
conflicts: noConflict('pnpm', 'select'),
conflicts: noConflict(Option.Pnpm, Option.Select),
})
.option('yarn', {
type: 'boolean',
description: desc.runWith('yarn'),
group: group.script,
alias: 'y',
conflicts: noConflict('yarn', 'select'),
conflicts: noConflict(Option.Yarn, Option.Select),
})
.option('bun', {
type: 'boolean',
description: desc.runWith('bun'),
group: group.script,
alias: 'b',
conflicts: noConflict('bun', 'select'),
conflicts: noConflict(Option.Bun, Option.Select),
})
.option('select', {
type: 'boolean',
Expand All @@ -87,20 +85,20 @@ const parsed = yargs(hideBin(process.argv))
description: 'Set the default package manager',
alias: 'd',
group: group.packageManager,
conflicts: noConflict('default'),
conflicts: noConflict(Option.Default),
})
.option('which', {
type: 'boolean',
description: 'Show which package which is currently used',
alias: 'w',
group: group.packageManager,
conflicts: noConflict('which'),
conflicts: noConflict(Option.Which),
})
.option('rename', {
type: 'string',
description: 'Rename the command',
group: group.config,
conflicts: noConflict('rename'),
conflicts: noConflict(Option.Rename),
})
.help()
.version(PACKAGE_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env node

import { args } from './args.js';
import { renameCommand } from './create-app/rename-command.js';
import {
currentPackageManager,
defaultPackageManager,
} from './package-manager/index.js';
import { selectScript } from './select-script.js';
import { updateTmp } from './update-tmp.js';
import { args } from './utils/args.js';
import { logger } from './utils/logger.js';

(async function main() {
Expand Down
2 changes: 1 addition & 1 deletion src/select-script.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import $_ from '@lexjs/prompts';

import { args } from './utils/args.js';
import { args } from './args.js';
import { getArgs } from './utils/get-args.js';
import { getPackageJson } from './utils/get-package-json.js';
import { logger } from './utils/logger.js';
Expand Down
2 changes: 1 addition & 1 deletion src/update-tmp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { args } from './args.js';
import { getConfigData } from './config/get-config-data.js';
import { useCoreHooks } from './hooks/use-core-hooks.js';
import { getProjectPm } from './package-manager/utils/get-project-pm.js';
import { args } from './utils/args.js';
import { getArgs } from './utils/get-args.js';

const { passThroughArgs } = getArgs();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/get-args.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { args } from './args.js';
import { args } from '../args.js';

const toString = (value: string | number): string => `${value}`;
const _ = args._.map(toString);
Expand Down