mirror of https://github.com/certd/certd
chore: 同步npm镜像
parent
1779e34773
commit
f30afac47e
100
deploy.js
100
deploy.js
|
@ -1,58 +1,79 @@
|
||||||
const http = require("axios")
|
import http from 'axios'
|
||||||
const exec = require('child_process').exec;
|
import fs from 'fs'
|
||||||
|
|
||||||
//builder
|
//读取 packages/core/pipline/package.json的版本号
|
||||||
function execute(cmd){
|
import { default as packageJson } from './packages/core/pipeline/package.json' assert { type: "json" };
|
||||||
return new Promise((resolve,reject)=>{
|
console.log("certdVersion", packageJson.version)
|
||||||
console.log("cmd executing: " + cmd)
|
|
||||||
exec(cmd, function(error, stdout, stderr) {
|
// 同步npmmirror的包
|
||||||
if(error){
|
async function getPackages(directoryPath) {
|
||||||
console.error(error);
|
return new Promise((resolve, reject) => {
|
||||||
console.info(stderr)
|
// 读取目录下的文件和目录列表
|
||||||
reject(error)
|
fs.readdir(directoryPath, {withFileTypes: true}, (err, files) => {
|
||||||
}
|
if (err) {
|
||||||
else{
|
console.log('无法读取目录:', err);
|
||||||
console.info(stdout)
|
reject(err)
|
||||||
console.log("success");
|
return;
|
||||||
resolve(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 过滤仅保留目录
|
||||||
|
const directories = files
|
||||||
|
.filter(file => file.isDirectory())
|
||||||
|
.map(directory => directory.name);
|
||||||
|
|
||||||
|
console.log('目录列表:', directories);
|
||||||
|
resolve(directories)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function build(){
|
async function getAllPackages(){
|
||||||
await execute("cd ./packages/fast-admin/fs-admin-antdv/ && npm run build")
|
const base = await getPackages("./packages/core")
|
||||||
await execute("cd ./packages/fast-admin/fs-admin-element/ && npm run build")
|
const plugins =await getPackages("./packages/plugins")
|
||||||
await execute("cd ./packages/fast-admin/fs-admin-naive-ui/ && npm run build")
|
|
||||||
await execute("npm run docs:build")
|
return base.concat(plugins)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function sync(){
|
||||||
|
const packages = await getAllPackages()
|
||||||
|
for(const pkg of packages){
|
||||||
|
await http({
|
||||||
|
url: `https://registry-direct.npmmirror.com/@certd/${pkg}/sync?sync_upstream=true`,
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
data: {}
|
||||||
|
})
|
||||||
|
console.log(`sync success:${pkg}`)
|
||||||
|
await sleep(1000)
|
||||||
|
}
|
||||||
|
await sleep(60000)
|
||||||
|
}
|
||||||
|
|
||||||
|
// curl -X PUT https://registry-direct.npmmirror.com/@certd/plugin-cert/sync?sync_upstream=true
|
||||||
|
|
||||||
// trigger
|
const certdImageBuild = "http://flow-openapi.aliyun.com/pipeline/webhook/4zgFk3i4RZEMGuQzlOcI"
|
||||||
|
const webhooks = [certdImageBuild]
|
||||||
|
|
||||||
const naive = "http://flow-openapi.aliyun.com/pipeline/webhook/Zm3TJyDtyFZgV4dtJiD1"
|
async function sleep(time) {
|
||||||
const doc = "http://flow-openapi.aliyun.com/pipeline/webhook/soOYdQ5sF3kLjTPJGmIO"
|
|
||||||
const antdv = "http://flow-openapi.aliyun.com/pipeline/webhook/HiL0uVYxfUnBzIMJZVXB"
|
|
||||||
const element = "http://flow-openapi.aliyun.com/pipeline/webhook/uFTI0XJ9RgqnofX7jpRD"
|
|
||||||
|
|
||||||
const webhooks = [doc,naive,antdv,element]
|
|
||||||
|
|
||||||
async function sleep(time){
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(resolve,time)
|
setTimeout(resolve, time)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function trigger(){
|
async function triggerBuild() {
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
await http({
|
await http({
|
||||||
url:webhook,
|
url: webhook,
|
||||||
method:'POST',
|
method: 'POST',
|
||||||
headers:{
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
data:{}
|
data: {
|
||||||
|
'CERTD_VERSION': certdVersion
|
||||||
|
}
|
||||||
})
|
})
|
||||||
console.log(`webhook success:${webhook}`)
|
console.log(`webhook success:${webhook}`)
|
||||||
await sleep(1000)
|
await sleep(1000)
|
||||||
|
@ -60,11 +81,12 @@ async function trigger(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function start(){
|
async function start() {
|
||||||
// await build()
|
// await build()
|
||||||
console.log("等待60秒")
|
console.log("等待60秒")
|
||||||
await sleep(60*1000)
|
await sleep(60 * 1000)
|
||||||
await trigger()
|
await sync()
|
||||||
|
await triggerBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
start()
|
start()
|
||||||
|
|
|
@ -6,8 +6,8 @@ WORKDIR /app/
|
||||||
#RUN npm install pm2 -g --registry=https://registry.npmmirror.com
|
#RUN npm install pm2 -g --registry=https://registry.npmmirror.com
|
||||||
#RUN pm2 install pm2-logrotate
|
#RUN pm2 install pm2-logrotate
|
||||||
ADD ./workspace/certd-server/ /app/
|
ADD ./workspace/certd-server/ /app/
|
||||||
#RUN yarn install --production --registry=https://registry.npmmirror.com
|
RUN yarn install --production --registry=https://registry.npmmirror.com
|
||||||
RUN yarn install --production
|
#RUN yarn install --production
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
#CMD ["pm2-runtime", "start", "./bootstrap.js","--name", "certd","-i","1"]
|
#CMD ["pm2-runtime", "start", "./bootstrap.js","--name", "certd","-i","1"]
|
||||||
CMD ["npm", "run","start"]
|
CMD ["npm", "run","start"]
|
||||||
|
|
10
package.json
10
package.json
|
@ -5,20 +5,22 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lerna-lite/cli": "^2.4.0",
|
"@lerna-lite/cli": "^2.4.0",
|
||||||
"@lerna-lite/run": "^2.4.0",
|
"@lerna-lite/publish": "^2.4.0",
|
||||||
"@lerna-lite/publish": "^2.4.0"
|
"@lerna-lite/run": "^2.4.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "lerna bootstrap --hoist",
|
"start": "lerna bootstrap --hoist",
|
||||||
"i-all": "lerna link && lerna exec npm install ",
|
"i-all": "lerna link && lerna exec npm install ",
|
||||||
"publish": "npm run proxy && npm run prepublishOnly1 && lerna publish --conventional-commits && npm run afterpublishOnly",
|
"publish": "npm run proxy && npm run prepublishOnly1 && lerna publish --conventional-commits && npm run afterpublishOnly && npm run deploy",
|
||||||
"afterpublishOnly": "",
|
"afterpublishOnly": "",
|
||||||
"proxy": "npm config set proxy=http://127.0.0.1:10809",
|
"proxy": "npm config set proxy=http://127.0.0.1:10809",
|
||||||
"prepublishOnly1": "npm run before-build && lerna run build ",
|
"prepublishOnly1": "npm run before-build && lerna run build ",
|
||||||
"before-build": "cd ./packages/core/acme-client && time /t >build.md && git add ./build.md && git commit -m \"build: prepare to build\""
|
"before-build": "cd ./packages/core/acme-client && time /t >build.md && git add ./build.md && git commit -m \"build: prepare to build\"",
|
||||||
|
"deploy": "node deploy.js"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"axios": "^1.4.0",
|
||||||
"lodash": "^4.17.21"
|
"lodash": "^4.17.21"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
|
|
Loading…
Reference in New Issue