Skip to content

Commit

Permalink
update packages & new docs
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Mar 12, 2022
1 parent 440d897 commit c4a9492
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 52 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
"scripts": {
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs",
"docs:deploy": "GH=1 sh script/deploy-docs.sh",
"docs:deploy": "GH=1 sh scripts/deploy-docs.sh",
"server:start": "node app/bin/www",
"server:watch": "nodemon --config nodemon.json",
"server:watch:debug": "nodemon --config nodemon.json --inspect-brk",
"server:super": "supervisor app/bin/www",
"lib": "sh script/lib.sh",
"build:ui": "sh script/build-ui.sh",
"build:server": "rimraf app && sh script/build-server.sh",
"lib": "sh scripts/lib.sh",
"build:ui": "sh scripts/build-ui.sh",
"build:server": "rimraf app && sh scripts/build-server.sh",
"build": "rimraf lib es && node --max-old-space-size=8192 node_modules/.bin/rollup -c",
"build:types": "run-s build-temp-types roll-types",
"build-temp-types": "tsc --emitDeclarationOnly --outDir temp/ -p bin/",
"patch-types": "node script/patchTypes",
"patch-types": "node scripts/patchTypes",
"roll-types": "api-extractor run && rimraf temp",
"circular": "madge lib/ -c",
"dev": "cross-env BUILD_ENV=DEV rollup -c -w",
Expand Down
23 changes: 0 additions & 23 deletions script/reinstall.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion script/lib.sh → scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rsync -av --exclude=*.bak bin/conf/* lib/conf
# npx esbuild "bin/**/*.js" --bundle --platform=node --target=node10.4 --outdir=lib


pkg=$(node script/lib.js $*)
pkg=$(npx tscjs scripts/lib.ts $*)
let "errors |= $?"
if [ $errors == 1 ]; then
exit 0
Expand Down
File renamed without changes.
72 changes: 72 additions & 0 deletions scripts/reinstall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* 1eslint-disable no-console */
const os = require('os')
const fs = require('fs')
const path = require('path')
const { spawnSync, execSync } = require('child_process')
const cwd = process.cwd()

type TypeManagers = 'npm' | 'pnpm' | 'yarn' | string

const PACKAGE_NEXT = ['vue', 'vuex', 'vue-router']
const PACKAGE_MANAGERS: TypeManagers[] = ['yarn', 'pnpm', 'npm']

let pkg = fs.readFileSync(path.join(cwd, 'package.json')),
list = ['--registry', 'https://registry.npmmirror.com']

pkg = JSON.parse(pkg)
const dependencies = { ...pkg.devDependencies, ...pkg.dependencies }
const cmd = getPackageManager()

switch (cmd) {
case 'pnpm':
list = list.concat(['i', '-WD'])
break
case 'yarn':
list = list.concat(['add', '-WD'])
break
case 'npm':
list = list.concat(['i', '-D'])
break
default:
list = list.concat(['i', '-WD'])
break
}

// @next
for (let packageName in dependencies) {
if (PACKAGE_NEXT.includes(packageName)) packageName += '@next'
list.push(packageName)
}

// run install
if (list.length > 0) {
spawnSync(cmd, list, {
stdio: 'inherit',
shell: process.platform === 'win32' /*, env: { detached: true }*/
})
} else {
process.exit(1)
}

// 获取安装工具
function getPackageManager(): TypeManagers {
const { packageManager = '' } = pkg
if (packageManager) return packageManager.replace(/@.+$/, '')
for (const manager of PACKAGE_MANAGERS) {
if (which(manager)) return manager
}
return 'npm'
}

function which(cmd: string): Boolean {
try {
execSync(
os.platform() === 'win32'
? `cmd /c "(help ${cmd} > nul || exit 0) && where ${cmd} > nul 2> nul"`
: `command -v ${cmd}`
)
return true
} catch {
return false
}
}
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"less-loader": "^10.2.0",
"lint-staged": "^12.1.2",
"prettier": "^2.5.0",
"tsnd": "^1.0.2",
"typescript": "^4.5.2",
"unplugin-element-plus": "^0.1.3",
"unplugin-vue-components": "^0.17.2",
Expand Down
23 changes: 0 additions & 23 deletions ui/scripts/reinstall.js

This file was deleted.

72 changes: 72 additions & 0 deletions ui/scripts/reinstall.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* 1eslint-disable no-console */
const os = require('os')
const fs = require('fs')
const path = require('path')
const { spawnSync, execSync } = require('child_process')
const cwd = process.cwd()

type TypeManagers = 'npm' | 'pnpm' | 'yarn' | string

const PACKAGE_NEXT = ['vue', 'vuex', 'vue-router']
const PACKAGE_MANAGERS: TypeManagers[] = ['yarn', 'pnpm', 'npm']

let pkg = fs.readFileSync(path.join(cwd, 'package.json')),
list = ['--registry', 'https://registry.npmmirror.com']

pkg = JSON.parse(pkg)
const dependencies = { ...pkg.devDependencies, ...pkg.dependencies }
const cmd = getPackageManager()

switch (cmd) {
case 'pnpm':
list = list.concat(['i', '-WD'])
break
case 'yarn':
list = list.concat(['add', '-WD'])
break
case 'npm':
list = list.concat(['i', '-D'])
break
default:
list = list.concat(['i', '-WD'])
break
}

// @next
for (let packageName in dependencies) {
if (PACKAGE_NEXT.includes(packageName)) packageName += '@next'
list.push(packageName)
}

// run install
if (list.length > 0) {
spawnSync(cmd, list, {
stdio: 'inherit',
shell: process.platform === 'win32' /*, env: { detached: true }*/
})
} else {
process.exit(1)
}

// 获取安装工具
function getPackageManager(): TypeManagers {
const { packageManager = '' } = pkg
if (packageManager) return packageManager.replace(/@.+$/, '')
for (const manager of PACKAGE_MANAGERS) {
if (which(manager)) return manager
}
return 'npm'
}

function which(cmd: string): Boolean {
try {
execSync(
os.platform() === 'win32'
? `cmd /c "(help ${cmd} > nul || exit 0) && where ${cmd} > nul 2> nul"`
: `command -v ${cmd}`
)
return true
} catch {
return false
}
}

1 comment on commit c4a9492

@vercel
Copy link

@vercel vercel bot commented on c4a9492 Mar 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.