Skip to content

Commit

Permalink
feat: create cli package (#37)
Browse files Browse the repository at this point in the history
* refactor: move the template inside

* feat: cli to create

* chore: bump dependencies

* fix: adapt to new esbuild api to build

* chore: fix dev build for project

* chore: setup automation

* chore: use node 15

* docs: update i18n

* feat: support the multi-window!

* style: fix the lint

* chore: should not pack the root github actions

* refactor: revert the env support as the vite 2 change its API

* docs: update i18n

* docs: update the main docs

* fix: correct the typing issue of the vetur
  • Loading branch information
ci010 authored Jan 12, 2021
1 parent d85735f commit 9bc60f3
Show file tree
Hide file tree
Showing 94 changed files with 8,995 additions and 2,744 deletions.
Empty file removed .env
Empty file.
1 change: 0 additions & 1 deletion .env.development

This file was deleted.

1 change: 0 additions & 1 deletion .env.production

This file was deleted.

File renamed without changes.
17 changes: 17 additions & 0 deletions .github/actions/update-version/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { writeFileSync, readFileSync } = require("fs");

function main(input) {
const version = input('version')

if (version) {
const package = JSON.parse(readFileSync('./package.json'))
package.version = version
writeFileSync('./package.json', JSON.stringify(package, null, 2))
}
}

function getInput(name) {
return process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
}

main(getInput);
File renamed without changes.
112 changes: 40 additions & 72 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ on:
branches:
- master
paths:
- 'build/**'
- 'electron-vue-next/build/**'
- 'electron-vue-next/scripts/*'
- 'electron-vue-next/src/**'
- 'electron-vue-next/static/**'
- 'electron-vue-next/package.json'
- 'electron-vue-next/package-lock.json'
- 'scripts/*'
- 'src/**'
- 'static/**'
- 'package.json'
- 'package-lock.json'
- 'index.js'

jobs:
build:
Expand All @@ -20,20 +22,12 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
- name: Use Node.js 15
uses: actions/setup-node@v2
with:
node-version: 12
# - name: Get npm cache directory
# id: npm-cache
# run: |
# echo "::set-output name=dir::$(npm config get cache)"
# - uses: actions/cache@v1
# with:
# path: ${{ steps.npm-cache.outputs.dir }}
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
node-version: 15
- name: Use npm 7
run: npm install -g npm@7
- name: Install
run: |
npm ci --no-optional
Expand All @@ -46,39 +40,19 @@ jobs:
env:
BUILD_NUMBER: ${{ steps.vars.outputs.build_number }}
FULL_RELEASE: ${{ startsWith(github.event.commits[0].message, 'chore(release)') }}
# If you build nsis web, you should uncomment below
# - name: Upload Web Build
# uses: actions/upload-artifact@v2
# with:
# name: build
# path: build/nsis-web/*.*
- name: Upload Build
uses: actions/upload-artifact@v2
with:
name: build
path: build/*.*
- name: Upload Windows Asar
if: ${{ runner.os == 'Windows' && startsWith(github.event.commits[0].message, 'chore(release)') }}
uses: actions/upload-artifact@v2
with:
name: build
path: build/win-unpacked/resources/app.asar

repare-release:
runs-on: ubuntu-latest
needs: build
if: ${{ !startsWith(github.event.commits[0].message, 'chore(release)') }}
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- name: Fetch All
run: git fetch --prune --unshallow
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
- name: Use Node.js 15
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
node-version: 15
- name: Use npm 7
run: npm install -g npm@7
- name: Install
run: |
npm ci --no-optional
Expand All @@ -95,13 +69,12 @@ jobs:
version: ${{ steps.package.outputs.version }}
tag-prefix: 'v'
- name: Update package.json and CHANGELOG.md
uses: ./.github/actions/update-version-changelog
uses: ./.github/actions/update-version
with:
version: ${{ steps.version.outputs.version }}
changelog: ${{ steps.version.outputs.changelog }}
- name: Create Pull Request
if: ${{ steps.version.outputs.skipped == 'false' }}
uses: peter-evans/create-pull-request@v2
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: >-
Expand All @@ -116,38 +89,27 @@ jobs:
needs: build
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
- name: Use Node.js 15
uses: actions/setup-node@v2
with:
node-version: 12
- name: Fetch All
run: git fetch --prune --unshallow
# - uses: actions/cache@v1
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
node-version: 15
- name: Use npm 7
run: npm install -g npm@7
- name: Install
run: |
npm ci --no-optional
- name: Download Build
uses: actions/download-artifact@v2
with:
name: build
path: build
- name: Publish NPM
run: |
git reset --hard
npm publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Get Package Version
uses: ./.github/actions/get-version
id: package
- name: Prepare Release
id: prepare_release
uses: ci010/conventional-changelog-action@master
with:
github-token: ${{ secrets.github_token }}
tag-prefix: 'v'
- name: Draft Release
- name: Create Release
id: create_release
uses: voxelum/create-release@master
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -156,4 +118,10 @@ jobs:
draft: false
prerelease: false
body: ${{ steps.prepare_release.outputs.clean_changelog }}
asset_dir_path: ./build
id: package
- name: Delete PR head branch
uses: dawidd6/action-delete-branch@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: prepare-release
be_kind: true # don't fail on errors (optional)
8 changes: 5 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
uses: actions/setup-node@v1
- name: Use Node.js 15
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 15
- name: Use npm 7
run: npm install -g npm@7
- name: Install
run: |
npm ci
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
node_modules
.DS_Store
dist
build/*
!build/icons
*.local
thumbs.db
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
.DS_Store
*.local
thumbs.db
package-lock.json
vetur.config.js
docs
scripts
.gitignore
/.github
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This repository contains the starter template for using vue-next with the latest

You can see the document [here](https://ci010.github.io/electron-vue-next/index.html).

同样,我们也有[中文文档](https://ci010.github.io/electron-vue-next/zh)

## Features

- Electron 10
Expand All @@ -24,21 +26,19 @@ You can see the document [here](https://ci010.github.io/electron-vue-next/index.
- Integrate VSCode well
- Support debug .ts/.vue files in main/renderer process by vscode debugger
- Detail see [Debug](#debug-in-vscode) section
- Multiple Windows Support
- Can add a new window for App easily. See [Add a New Window](#new-window) section

## Planned Features

- Multi-Windows Support
- This need to wait vite support [#257](https://github.com/vitejs/vite/issues/257)
- Currently, all workarounds I can come up with are all ugly and not ideal enough...
- Make tsconfig.json less confusing
- Due to the Vetur [limitation](https://github.com/vuejs/vetur/issues/424) (only the root tsconfig.json is used for vetur), the current root tsconfig.json might be confusing
- [vue-devtool](https://github.com/vuejs/vue-devtools) support
- Currently the devtool is still WIP and not support vuex/router...
- Wait until it has great support for vuex and router to add it

## Getting Started

Clone or fork this project to start.
Run `npm init electron-vue-next`

Once you have your project, and in the project folder:

```shell
Expand Down
20 changes: 3 additions & 17 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ const themeConfig = {
nextLink: true,
locales: {
'/': {
docsDir: 'docs',
lang: 'en-US',
title: 'vue-electron-next',
description: 'vue hooks',
label: 'English',
selectText: 'Languages',
},
'/zh/': {
docsDir: 'docs',
lang: 'zh-CN',
title: 'vue-electron-next',
description: 'vue hooks',
Expand All @@ -36,24 +38,8 @@ const themeConfig = {
const config = {
lang: 'en-US',
themeConfig,
base: '/electron-vue-next',
base: process.env.NODE_ENV === 'development' ? undefined : '/electron-vue-next',
title: 'Electron Vue Next',
locales: {
'/': {
lang: 'en-US',
title: 'vue-electron-next',
description: 'vue hooks',
label: 'English',
selectText: 'Languages',
},
'/zh/': {
lang: 'zh-CN',
title: 'vue-electron-next',
description: 'vue hooks',
label: '中文',
selectText: '语言',
},
},
}

module.exports = config;
Loading

0 comments on commit 9bc60f3

Please sign in to comment.