diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..270797b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# node modules +node_modules/ + +# build files +dist/ diff --git a/build.js b/build.js new file mode 100644 index 0000000..3e05875 --- /dev/null +++ b/build.js @@ -0,0 +1,12 @@ +// 将当前时间写入dist/index.html +console.log('start build'); +const fs = require('fs'); +const path = require('path'); +const moment = require('moment'); +const buildTime = moment().format('YYYY-MM-DD HH:mm:ss'); +const indexPath = path.resolve(__dirname, 'index.html'); +const distIndexPath = path.resolve(__dirname, 'dist/index.html'); +const indexContent = fs.readFileSync(indexPath, 'utf-8'); +const newIndexContent = indexContent.replace(/.*<\/span>/, `${buildTime}`); +fs.writeFileSync(distIndexPath, newIndexContent, 'utf-8'); +console.log('build success'); diff --git a/dist/.gitkeep b/dist/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/index.html b/index.html new file mode 100644 index 0000000..b0228d4 --- /dev/null +++ b/index.html @@ -0,0 +1,12 @@ + + + + + + Document + Unk Time + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..fbde2d1 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "ci-publish-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "build": "node build.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "moment": "^2.30.1" + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..370c8c7 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,22 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + moment: + specifier: ^2.30.1 + version: 2.30.1 + +packages: + + moment@2.30.1: + resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==} + +snapshots: + + moment@2.30.1: {}