diff --git a/.github/workflows/npm-publish.yaml b/.github/workflows/npm-publish.yaml new file mode 100644 index 0000000..90e2b6d --- /dev/null +++ b/.github/workflows/npm-publish.yaml @@ -0,0 +1,32 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: "Publish package @raojinlin/create-chrome-extension" + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm ci + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish --access=public + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/README.md b/README.md index a500812..4c142bd 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ `@raojinlin/create-chrome-extension`可以快速生成一个使用React和Ant Destign的Chrome扩展应用。 +[![asciicast](https://asciinema.org/a/608318.svg)](https://asciinema.org/a/608318) + ## 创建扩展应用 1. 确保你的计算机上已经安装了Node.js的版本为16.0.0或更高版本。如果尚未安装,请访问Node.js官方网站(https://nodejs.org/)并按照指示安装。 diff --git a/index.js b/index.js index c25415a..748cadf 100644 --- a/index.js +++ b/index.js @@ -1,3 +1 @@ -const clone = require('git-clone/promise'); - -clone('', '') \ No newline at end of file +require('./tasks/cre'); diff --git a/package.json b/package.json index 2b9e328..8403713 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@raojinlin/create-chrome-extension", - "version": "1.0.1", + "version": "1.0.0", "description": "Set up a chrome extension by running one command. ", "main": "index.js", "scripts": { diff --git a/tasks/cre.js b/tasks/cre.js index 828bd1c..51ee66b 100755 --- a/tasks/cre.js +++ b/tasks/cre.js @@ -10,8 +10,6 @@ const { version } = require('../package.json'); async function cre() { - const packageJson = require('../packages/chrome-extension-react-antd-template/package.json'); - const rootDir = path.dirname(__dirname, '..'); const packagesDir = path.join(rootDir, 'packages'); const templateDir = path.join(packagesDir, 'chrome-extension-react-antd-template') @@ -48,18 +46,18 @@ async function cre() { await generateManifestJSON(projectDir); console.log('🤖 Installing packages. This might take a couple of minutes....'); - // process.chdir(projectDir); - // const installProc = child_process.spawn('npm', ['install'], {env: process.env}); - // installProc.stdout.pipe(process.stdout); - // installProc.stderr.pipe(process.stderr); + process.chdir(projectDir); + const installProc = child_process.spawn('npm', ['install'], {env: process.env}); + installProc.stdout.pipe(process.stdout); + installProc.stderr.pipe(process.stderr); - // installProc.on('error', e => { - // console.error('Install error', e); - // }); + installProc.on('error', e => { + console.error('Install error', e); + }); - // installProc.on('exit', e => { - // console.log('Packages install success.'); - // }); + installProc.on('exit', e => { + console.log('Packages install success.'); + }); } cre(); \ No newline at end of file