Skip to content

Commit

Permalink
Merge remote-tracking branch 'bp/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Aug 21, 2023
2 parents 59cba5f + 03b6f67 commit c8798a0
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 45 deletions.
14 changes: 10 additions & 4 deletions .githooks/gen-file-from-example.ts → .githooks/gen-file-from-example.mts
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#!/usr/bin/env ts-node-esm
#!/usr/bin/env tsx
/**
* 搜索指定目录以 file.example 文件为基础生成不带后缀的文件为不带 .example 后缀的文件
*/
import { dirname, join } from 'node:path'
import { dirname, join, sep } from 'node:path'
import { cp, mkdir, readdir } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'

import { folderArr, globalConfigFileArr } from './init.config.js'
import { genFileFromExample } from './init-example-file.js'


const currentURL = import.meta.url
const currentPath = fileURLToPath(currentURL)
const currentDir = dirname(currentPath)
const currentFileName = currentPath.split(sep).pop()
const rootDir = join(currentDir, '..')
console.log({ rootDir, currentFileName })

const pkgEntryName = 'packages'
const rootDir = join(process.cwd(), '..')
console.log({ rootDir })
const pkgBase = join(rootDir, pkgEntryName)

const files = await cpGlobalConfigsToPkgs(rootDir, globalConfigFileArr, pkgBase)
Expand Down
4 changes: 3 additions & 1 deletion .githooks/init-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ if [ -z "$CI" ]; then
fi;

echo It may going for a long time. Plese wait...
cd .githooks && node --loader ts-node/esm gen-file-from-example.ts && cd -
.githooks/gen-file-from-example.mts

nx reset
lerna list
echo init done
4 changes: 4 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

sh .githooks/set-scripts-executable.sh

3 changes: 2 additions & 1 deletion .githooks/set-scripts-executable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ set +e
dirs=" .githooks .scripts .github"

for dir in $dirs; do
find $dir -type f -iname "*.sh" -print0 | xargs -0II git update-index --ignore-missing --chmod=+x I
find $dir -type f -iname "*.sh" -print0 | xargs -0II git update-index --ignore-missing --chmod=+x I
find $dir -type f -iname "*.mts" -print0 | xargs -0II git update-index --ignore-missing --chmod=+x I
find $dir -type f -iname "*.mjs" -print0 | xargs -0II git update-index --ignore-missing --chmod=+x I
done

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nodejs-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
with:
path: |
node_modules
node_modules/.cache/nx
# node_modules/.cache/nx
package-lock.json
packages/*/.eslintcache
# packages/*/.eslintcache
packages/*/.tsbuildinfo
packages/*/.vscode
packages/*/dist
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
shell: bash
run: |
export cwd=`pwd`
npm i --no-audit -g autocannon c8 lerna rollup zx
npm i --no-audit -g autocannon c8 lerna rollup tsx zx
# npm run purge
npm i
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
with:
path: |
node_modules
node_modules/.cache/nx
# node_modules/.cache/nx
package-lock.json
packages/*/.eslintcache
# packages/*/.eslintcache
packages/*/.tsbuildinfo
packages/*/.vscode
packages/*/dist
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
# DO NOT execute: npm config set unsafe-perm=true
export cwd=`pwd`
# .github/workflows/fix.sh
npm i --no-audit -g autocannon c8 lerna rollup zx
npm i --no-audit -g autocannon c8 lerna rollup tsx zx
# npm run purge
npm i
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
# DO NOT execute: npm config set unsafe-perm=true
export cwd=`pwd`
.github/workflows/fix.sh
npm i --no-audit -g autocannon c8 lerna rollup zx
npm i --no-audit -g autocannon c8 lerna rollup tsx zx
# npm run purge
npm run bootstrap
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish-wo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
# DO NOT execute: npm config set unsafe-perm=true
export cwd=`pwd`
.github/workflows/fix.sh
npm i --no-audit -g autocannon c8 lerna rollup zx
npm i --no-audit -g autocannon c8 lerna rollup tsx zx
# npm run purge
npm run bootstrap
env:
Expand Down
1 change: 1 addition & 0 deletions .scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
. .scripts/env.sh

input="$@"
scope=''
Expand Down
3 changes: 3 additions & 0 deletions .scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

export NODE_OPTIONS="${NODE_OPTIONS} --no-warnings"

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Create my CA center, generate a self signed x509 certificate, issue server certi
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lernajs.io/)



## 安装全局依赖
```sh
npm i -g c8 lerna rollup tsx
```

## Installing
```bash
npm install --save myca
Expand Down
23 changes: 11 additions & 12 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@
],
"verifyAccess": false
},
"bootstrap": {
"hoist": true,
"noCi": true,
"nohoist": [
"cross-env",
"egg"
],
"npmClientArgs": [
"--no-audit"
]
},
"version": {
"conventionalCommits": true,
"allowBranch": [
"main",
"fix",
"release",
"fix"
"versioning_*"
],
"ignoreChanges": [
"*.md",
".githooks",
".scripts",
".vscode",
"package-lock.json",
"packages/demo",
"packages/mw-demo"
],
"registry": "https://registry.npmjs.org/"
}
Expand Down
31 changes: 15 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
"@commitlint/cli": "17",
"@commitlint/config-conventional": "17",
"@midwayjs/cli": "^2.1.1",
"@midwayjs/mock": "^3.11.15",
"@midwayjs/web": "^3.11.15",
"@midwayjs/mock": "^3.12.2",
"@midwayjs/web": "^3.12.2",
"@rollup/plugin-commonjs": "25",
"@rollup/plugin-node-resolve": "15",
"@types/mocha": "10",
"@types/node": "20",
"@waiting/eslint-config": "^8.8.0",
"@waiting/shared-core": "^21.3.0",
"@waiting/shared-types": "^21.3.0",
"@waiting/shared-core": "^21.4.2",
"@waiting/shared-types": "^21.4.0",
"autocannon": "7",
"coveralls": "3",
"cross-env": "7",
"debug": "^4.3.4",
"eslint": "^8.47.0",
"eslint": "8",
"madge": "^6.1.0",
"mocha": "10",
"mocha-lcov-reporter": "1",
"rimraf": "5",
"rollup-plugin-dts": "^5.3.0",
"nx": "16",
"rollup-plugin-dts": "6",
"ts-node": "^10.9.1",
"tsc-alias": "^1.8.7",
"tsconfig-paths": "4",
Expand All @@ -44,28 +44,27 @@
"bp:add": "git remote add bp https://github.com/waitingsong/npm-mono-base",
"bp:sync": "git fetch --all -v && git pull origin && git merge bp/main -m \"Merge remote-tracking branch 'bp/main'\" ",
"bp:syncxo": "git fetch --all -v && git pull origin && git merge bp/main -m \"Merge remote-tracking branch 'bp/main'\" -Xours",
"bootstrap": "npm i --loglevel info",
"bootstrap2": "npm i -legacy-peer-deps",
"postbootstrap": "npm run repo:init",
"bootstrap": "npm i --loglevel info --disturl=https://npmmirror.com/dist/",
"build": "sh .scripts/build.sh",
"ci": "npm run cov",
"clean": "lerna clean --loglevel error --yes & lerna run clean",
"clean:dist": "rm -rf packages/*/dist/ & rm -rf packages/*/.vscode/",
"clean": "lerna clean --loglevel error --yes && lerna run clean",
"clean:cache": "rm -f packages/*/.eslintcache packages/*/.tsbuildinfo",
"clean:dist": "rm -rf packages/*/dist/ packages/*/.tsbuildinfo",
"cov": "sh .scripts/cov.sh",
"lint": "sh .scripts/lint.sh",
"lint:cycle": "lerna exec -- madge --circular --extensions ts src",
"lint:nofix": "sh .scripts/lint-no-fix.sh",
"lint:s": "sh .scripts/lint-no-fix-s.sh",
"postbuild": "rm -rf packages/*/dist/.mwcc-cache",
"postinstall": "npm run repo:init",
"pub": "bash .scripts/publish.sh --conventional-commits --create-release github",
"postpublish": "rm -rf packages/*/npm-shrinkwrap.json",
"pub": "bash .scripts/publish.sh --no-private --conventional-commits --create-release github",
"pub:canary": "bash .scripts/publish.sh --canary",
"pub:beta": "bash .scripts/publish.sh --dist-tag beta --force-publish=*",
"pub:next": "bash .scripts/publish.sh --dist-tag next",
"purge": "npm run clean & lerna run purge & rm node_modules -rf & rm package-lock.json -f & nx reset",
"postpurge": "npm run refresh",
"purge": "npm run clean && lerna run purge && nx reset && rm node_modules -rf && rm package-lock.json -f && npm run refresh",
"repo:init": "sh .githooks/init-repo.sh",
"refresh": "npm run bootstrap && npm run build",
"refresh": "npm i && npm run build",
"test": "lerna run test",
"ptest": "sh .scripts/test.sh"
}
Expand Down
10 changes: 7 additions & 3 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,30 @@
"files": [
"README.*.md",
"Dockerfile",
"npm-shrinkwrap.json",
"tsconfig.json",
"tsconfig.base.json",
"src/**/*.ts",
"bin/*.js",
"dist"
"dist",
"!**/*.spec.*",
"!**/*.tsbuildinfo"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "npm run tsc && tsc-alias && npm run rp",
"clean": "npm run clean:lock & npm run clean:cache & rm -rf dist/*",
"clean": "npm run clean:lock && npm run clean:cache && npm run clean:dist && npm run clean:log",
"clean:cache": "rm -rf .eslintcache .tsbuildinfo",
"clean:dist": "rm -rf dist/* .tsbuildinfo",
"clean:lock": "rm package-lock.json -f",
"clean:log": "rm -rf ./logs ./run",
"cov": "cross-env TS_NODE_PROJECT=test/tsconfig.json c8 mocha --parallel=false",
"lint": "eslint --fix --cache {src,test}/**/*.ts",
"lint:nofix": "eslint --cache {src,test}/**/*.ts",
"purge": "npm run clean && rm node_modules -rf",
"rp": "rollup -c rollup.config.js --context this",
"prepack": "rm -f dist/tsconfig.tsbuildinfo",
"pretest": "npm run build",
"pretest:local": "npm run build",
"test": "cross-env TS_NODE_PROJECT=test/tsconfig.json mocha",
Expand Down

0 comments on commit c8798a0

Please sign in to comment.