Skip to content

Commit

Permalink
chore(projects): update deps & update @sa/scripts config
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Dec 14, 2023
1 parent 87aa069 commit 31f676a
Show file tree
Hide file tree
Showing 9 changed files with 851 additions and 462 deletions.
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"lint": "eslint . --fix",
"prepare": "simple-git-hooks",
"preview": "vite preview",
"release": "sa release",
"release": "soy release",
"typecheck": "vue-tsc --noEmit --skipLibCheck",
"update-pkg": "sa update-pkg"
},
Expand All @@ -43,10 +43,11 @@
},
"devDependencies": {
"@elegant-router/vue": "0.3.1",
"@iconify/json": "2.2.154",
"@iconify/json": "2.2.157",
"@sa/scripts": "workspace:*",
"@sa/uno-preset": "workspace:*",
"@soybeanjs/eslint-config": "1.0.11",
"@soybeanjs/cli": "1.0.0-beta.7",
"@soybeanjs/eslint-config": "1.1.2",
"@types/lodash-es": "4.17.12",
"@types/node": "20.10.4",
"@types/nprogress": "0.2.3",
Expand All @@ -64,13 +65,14 @@
"npm-run-all": "4.1.5",
"sass": "1.69.5",
"simple-git-hooks": "2.9.0",
"tsx": "4.6.2",
"typescript": "5.3.3",
"unplugin-icons": "0.18.1",
"unplugin-vue-components": "0.26.0",
"vite": "5.0.7",
"vite": "5.0.8",
"vite-plugin-progress": "0.0.7",
"vite-plugin-svg-icons": "2.0.1",
"vite-plugin-vue-devtools": "1.0.0-rc.7",
"vite-plugin-vue-devtools": "1.0.0-rc.8",
"vue-eslint-parser": "9.3.2",
"vue-tsc": "1.8.25"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
"./vue": "./configs/vue.js"
},
"devDependencies": {
"@types/eslint": "8.44.8",
"@typescript-eslint/eslint-plugin": "6.13.2",
"@typescript-eslint/parser": "6.13.2",
"@types/eslint": "8.44.9",
"@typescript-eslint/eslint-plugin": "6.14.0",
"@typescript-eslint/parser": "6.14.0",
"eslint": "8.55.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-n": "16.3.1",
"eslint-plugin-n": "16.4.0",
"eslint-plugin-prettier": "5.0.1",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-vue": "9.19.2",
Expand Down
6 changes: 0 additions & 6 deletions packages/scripts/bin.cjs

This file was deleted.

3 changes: 3 additions & 0 deletions packages/scripts/bin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env tsx

import './src/index.ts';
8 changes: 4 additions & 4 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@sa/scripts",
"version": "1.0.0",
"bin": {
"sa": "./bin.cjs"
"sa": "./bin.ts"
},
"exports": {
".": "./src/index.ts"
Expand All @@ -13,14 +13,14 @@
}
},
"devDependencies": {
"bumpp": "9.2.1",
"c12": "1.5.1",
"cac": "6.7.14",
"consola": "3.2.3",
"enquirer": "2.4.1",
"execa": "8.0.1",
"jiti": "1.21.0",
"lint-staged": "15.2.0",
"npm-check-updates": "16.14.11",
"kolorist": "^1.8.0",
"npm-check-updates": "16.14.12",
"rimraf": "5.0.5"
}
}
25 changes: 1 addition & 24 deletions packages/scripts/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import process from 'node:process';
import { loadConfig } from 'c12';
import type { CliOption } from '../types';

const eslintExt = '*.{js,jsx,mjs,cjs,ts,tsx,vue}';

const defaultOptions: CliOption = {
cwd: process.cwd(),
cleanupDirs: [
Expand Down Expand Up @@ -38,28 +36,7 @@ const defaultOptions: CliOption = {
['release', 'release project'],
['other', 'other changes']
],
ncuCommandArgs: ['--deep', '-u'],
prettierWriteGlob: [
`!**/${eslintExt}`,
'!*.min.*',
'!CHANGELOG.md',
'!dist',
'!LICENSE*',
'!output',
'!coverage',
'!public',
'!temp',
'!package-lock.json',
'!pnpm-lock.yaml',
'!yarn.lock',
'!.github',
'!__snapshots__',
'!node_modules'
],
lintStagedConfig: {
[eslintExt]: 'eslint --fix',
'*': 'sa prettier-write'
}
ncuCommandArgs: ['--deep', '-u']
};

export async function loadCliOptions(overrides?: Partial<CliOption>, cwd = process.cwd()) {
Expand Down
18 changes: 16 additions & 2 deletions packages/scripts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ type CommandAction<A extends object> = (args?: A) => Promise<void> | void;
type CommandWithAction<A extends object = object> = Record<Command, { desc: string; action: CommandAction<A> }>;

interface CommandArg {
total?: boolean;
/**
* The glob pattern of dirs to cleanup
*
* If not set, it will use the default value
*
* Multiple values use "," to separate them
*/
cleanupDir?: string;
}

export async function setupCli() {
Expand All @@ -24,7 +31,14 @@ export async function setupCli() {
const commands: CommandWithAction<CommandArg> = {
cleanup: {
desc: 'delete dirs: node_modules, dist, etc.',
action: async () => {
action: async args => {
const cleanupDirs = args?.cleanupDir?.split(',') || [];
const formattedDirs = cleanupDirs.map(dir => dir.trim()).filter(Boolean);

if (formattedDirs.length) {
cliOptions.cleanupDirs = formattedDirs;
}

await cleanup(cliOptions.cleanupDirs);
}
},
Expand Down
8 changes: 0 additions & 8 deletions packages/scripts/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,4 @@ export interface CliOption {
* @default ['--deep', '-u']
*/
ncuCommandArgs: string[];
/**
* Prettier write glob
*
* Glob pattern syntax {@link https://github.com/micromatch/micromatch}
*/
prettierWriteGlob: string[];
/** Lint-staged config */
lintStagedConfig: Record<string, string | string[]>;
}
Loading

0 comments on commit 31f676a

Please sign in to comment.