From 63e7b81cf5a298a38914442c6dd9eabed08d3cb4 Mon Sep 17 00:00:00 2001 From: DavidJones Date: Thu, 8 Feb 2024 18:56:06 +0800 Subject: [PATCH] chore: move file 1. move script to public and convert to mjs 2. move eslintrc to public/eslintrc folder --- .eslintrc.js | 8 ++++++-- @lib/util-lib/__tests__/polify/esm.mjs | 2 ++ package.json | 4 ++-- .eslintrc.javascript.js => public/eslintrc/cjs.js | 0 public/eslintrc/esm.js | 11 +++++++++++ .eslintrc.typescript.js => public/eslintrc/ts.js | 0 scripts/postinstall => public/scripts/postinstall.mjs | 11 +++++------ scripts/preinstall => public/scripts/preinstall.mjs | 2 -- 8 files changed, 26 insertions(+), 12 deletions(-) rename .eslintrc.javascript.js => public/eslintrc/cjs.js (100%) create mode 100644 public/eslintrc/esm.js rename .eslintrc.typescript.js => public/eslintrc/ts.js (100%) rename scripts/postinstall => public/scripts/postinstall.mjs (77%) rename scripts/preinstall => public/scripts/preinstall.mjs (87%) diff --git a/.eslintrc.js b/.eslintrc.js index aa420783..3c65f714 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -41,11 +41,15 @@ module.exports = { overrides: [ { files: ['**/*.ts'], - extends: ['.eslintrc.typescript.js'], + extends: ['./public/eslintrc/ts.js'], }, { files: ['**/*.js'], - extends: ['.eslintrc.javascript.js'], + extends: ['./public/eslintrc/cjs.js'], + }, + { + files: ['**/*.mjs'], + extends: ['./public/eslintrc/esm.js'], }, ], } diff --git a/@lib/util-lib/__tests__/polify/esm.mjs b/@lib/util-lib/__tests__/polify/esm.mjs index f0a06203..87b2dcd1 100644 --- a/@lib/util-lib/__tests__/polify/esm.mjs +++ b/@lib/util-lib/__tests__/polify/esm.mjs @@ -1 +1,3 @@ +/* eslint-disable */ + export const abc = 123 diff --git a/package.json b/package.json index 7747ebce..2ea4fd32 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "ci:pages": "shx rm -rf ./gh-pages && mkdir -p ./gh-pages && shx cp -rf ./coverage ./gh-pages/coverage && dumi build", "ci:coverage": "npm run compile && npm run test", "ci:build": "npm run compile", - "postinstall": "node ./scripts/postinstall", - "preinstall": "node ./scripts/preinstall", + "postinstall": "node ./public/scripts/postinstall.mjs", + "preinstall": "node ./public/scripts/preinstall.mjs", "clear": "rimraf --glob ./@*/*/{libs,build,*.tsbuildinfo,tsconfig.build.json} tsconfig.build.json", "format": "prettier --config .prettierrc.js --write \"**/*.{js,jsx,ts,tsx,d.ts,vue,md,json,yml,yaml}\"", "lint": "eslint --fix .", diff --git a/.eslintrc.javascript.js b/public/eslintrc/cjs.js similarity index 100% rename from .eslintrc.javascript.js rename to public/eslintrc/cjs.js diff --git a/public/eslintrc/esm.js b/public/eslintrc/esm.js new file mode 100644 index 00000000..f6de2d21 --- /dev/null +++ b/public/eslintrc/esm.js @@ -0,0 +1,11 @@ +module.exports = { + extends: ['eslint:recommended', 'prettier'], + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + }, + env: { + es6: true, + node: true, + }, +} diff --git a/.eslintrc.typescript.js b/public/eslintrc/ts.js similarity index 100% rename from .eslintrc.typescript.js rename to public/eslintrc/ts.js diff --git a/scripts/postinstall b/public/scripts/postinstall.mjs similarity index 77% rename from scripts/postinstall rename to public/scripts/postinstall.mjs index 34c52fda..ef180e81 100755 --- a/scripts/postinstall +++ b/public/scripts/postinstall.mjs @@ -1,22 +1,21 @@ -#!/usr/bin/env node +import fs from 'fs' +import { exec } from 'child_process' +import Spinnies from 'spinnies' ;(async function main () { - const fs = require('fs') - const { exec } = require('child_process') const tasks = ['tsc --build ./tsconfig.build.json'] - + if (!fs.existsSync('tsconfig.build.json')) { tasks.unshift(...[ 'ts-patch install -s', 'lerna run compile --concurrency 2 --parallel --include-dependencies --scope=@dumlj/tidy-cli', - 'dumlj concurrently \"tscfg --exclude \"**/__template__\" --exclude \"**/__example__\"\" \"deps --exclude \"**/__template__\" --exclude \"**/__example__\"\"', + 'dumlj concurrently "tscfg --exclude "**/__template__" --exclude "**/__example__"" "deps --exclude "**/__template__" --exclude "**/__example__""', 'npm run compile', // must compile create-cli 'dumlj install husky', ]) } - const Spinnies = require('spinnies') const spinnies = new Spinnies() tasks.forEach((command) => spinnies.add(command, { text: command })) diff --git a/scripts/preinstall b/public/scripts/preinstall.mjs similarity index 87% rename from scripts/preinstall rename to public/scripts/preinstall.mjs index 93f71962..fda59ec2 100644 --- a/scripts/preinstall +++ b/public/scripts/preinstall.mjs @@ -1,5 +1,3 @@ -#!/usr/bin/env node - if (!process.env.npm_execpath.match(/pnpm/)) { throw new Error('\x1b[31mPlease use pnpm@8.x to install. @see https://pnpm.io/pnpm-cli\x1b[0m') }