Skip to content

Commit 3ec23d6

Browse files
authored
chore: add AppVeyor integration (Kocal#289)
1 parent 9820379 commit 3ec23d6

File tree

12 files changed

+222
-10
lines changed

12 files changed

+222
-10
lines changed

.appveyor.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
environment:
2+
VUE_TEMPLATES: "minimal full full-airbnb"
3+
4+
cache:
5+
- node_modules
6+
- examples\full\node_modules
7+
- examples\full-airbnb\node_modules
8+
- examples\minimal\node_modules
9+
- '%APPDATA%\npm-cache'
10+
- '%USERPROFILE%\.npm'
11+
- '%USERPROFILE%\.cache'
12+
13+
install:
14+
- ps: Install-Product node 8
15+
- ps: Install-Module -Name PSWriteColor
16+
- ps: Install-Module -Name Assert
17+
- npm install -g yarn vue-cli
18+
- yarn install --frozen-lockfile --silent 2> $null
19+
20+
test_script:
21+
- ps: >-
22+
function Test-Extension() {
23+
Write-Color "Working inside ", (Get-Location).path, " folder..." -Color White, Yellow, White
24+
25+
Write-Color "[$($env:VUE_TEMPLATE)]", " Installing extension dependencies..." -Color Yellow, White
26+
yarn install --frozen-lockfile --silent 2> $null
27+
28+
Write-Color "[$($env:VUE_TEMPLATE)]", " Building extension..." -Color Yellow, White
29+
yarn build --silent 2> $null
30+
31+
Write-Color "[$($env:VUE_TEMPLATE)]", " Testing version behavior..." -Color Yellow, White
32+
Invoke-Expression "$($env:APPVEYOR_BUILD_FOLDER)/tests/test_version.ps1"
33+
34+
if ($env:VUE_TEMPLATE.startsWith('full')) {
35+
Write-Color "[$($env:VUE_TEMPLATE)]", " Linting..." -Color Yellow, White
36+
yarn lint --fix
37+
}
38+
39+
if ($env:VUE_TEMPLATE.startsWith('full')) {
40+
Write-Color "[$($env:VUE_TEMPLATE)]", " Prettying..." -Color Yellow, White
41+
yarn prettier:write
42+
}
43+
44+
if ($env:VUE_TEMPLATE.startsWith('full')) {
45+
Write-Color "[$($env:VUE_TEMPLATE)]", " Testing options..." -Color Yellow, White
46+
Invoke-Expression "$($env:APPVEYOR_BUILD_FOLDER)/tests/test_options.ps1"
47+
}
48+
49+
if ($env:VUE_TEMPLATE.startsWith('full')) {
50+
Write-Color "[$($env:VUE_TEMPLATE)]", " Testing axios..." -Color Yellow, White
51+
Invoke-Expression "$($env:APPVEYOR_BUILD_FOLDER)/tests/test_axios.ps1"
52+
}
53+
54+
if ($env:VUE_TEMPLATE.startsWith('full')) {
55+
Write-Color "[$($env:VUE_TEMPLATE)]", " Testing vue-router..." -Color Yellow, White
56+
Invoke-Expression "$($env:APPVEYOR_BUILD_FOLDER)/tests/test_router.ps1"
57+
}
58+
59+
if ($env:VUE_TEMPLATE.startsWith('full')) {
60+
Write-Color "[$($env:VUE_TEMPLATE)]", " Testing vuex..." -Color Yellow, White
61+
Invoke-Expression "$($env:APPVEYOR_BUILD_FOLDER)/tests/test_store.ps1"
62+
}
63+
}
64+
65+
function Create-Extension() {
66+
Param($Template)
67+
$env:VUE_TEMPLATE = $Template
68+
69+
cd "$($env:APPVEYOR_BUILD_FOLDER)/tests"
70+
Write-Color "[$($env:VUE_TEMPLATE)]", " Creating extension following ", $Template, " scenario..." -Color Yellow, White, Yellow, White
71+
vue init .. "extension-$($Template)"
72+
73+
cd "extension-$($Template)"
74+
Test-Extension
75+
}
76+
77+
function Main() {
78+
if($env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH.startsWith('dependabot')) {
79+
Write-Color "Dependabot PR detected" -Color Yellow
80+
$env:VUE_TEMPLATE = (git --no-pager diff --name-only origin/master | Select-String "examples" | Select-Object -Last 1 | Out-String | ForEach-Object { $_.Split('/')[1] })
81+
82+
if ($env:VUE_TEMPLATE -like "*$env:VUE_TEMPLATE*") {
83+
Write-Color "Running tests for $($env:VUE_TEMPLATE) example..." -Color Yellow
84+
cd "$($env:APPVEYOR_BUILD_FOLDER)/examples/$($env:VUE_TEMPLATE)"
85+
Test-Extension
86+
} else {
87+
Write-Color "Nothing to tests for global project..." -Color Orange
88+
exit 0
89+
}
90+
} else {
91+
foreach($VUE_TEMPLATE in $env:VUE_TEMPLATES.split(" ")) {
92+
Create-Extension -Template $VUE_TEMPLATE
93+
}
94+
}
95+
}
96+
97+
Main
98+
99+
build: off

.travis.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,32 @@ before_install:
6363
6464
- |
6565
# Setup jsdoc-vuejs bash utils
66-
extension_workflow () {
66+
test_extension () {
6767
set -e
6868
6969
tfold "Working inside \\e[1;33m$PWD\\e[0m folder..." echo $PWD
7070
tfold "Installing extension dependencies..." yarn install --frozen-lockfile
7171
tfold "Building extension..." yarn build
72-
tfold "Testing version behavior" $TRAVIS_BUILD_DIR/tests/test_version.sh
72+
tfold "Testing version behavior..." $TRAVIS_BUILD_DIR/tests/test_version.sh
7373
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Linting..." yarn lint --fix; fi
7474
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Prettying..." yarn prettier:write; fi
7575
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Testing options..." $TRAVIS_BUILD_DIR/tests/test_options.sh; fi
7676
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Testing axios..." $TRAVIS_BUILD_DIR/tests/test_axios.sh; fi
7777
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Testing vue-router..." $TRAVIS_BUILD_DIR/tests/test_router.sh; fi
7878
if [[ "$VUE_TEMPLATE" =~ ^full ]]; then tfold "Testing vuex..." $TRAVIS_BUILD_DIR/tests/test_store.sh; fi
7979
}
80-
export -f extension_workflow
80+
export -f test_extension
8181
82-
create_extension_workflow () {
82+
create_extension () {
8383
set -e
8484
export VUE_TEMPLATE=$1
8585
8686
cd $TRAVIS_BUILD_DIR/tests
8787
tfold "Creating extension following $VUE_TEMPLATE scenario..." vue init .. extension-$VUE_TEMPLATE &&
8888
cd $TRAVIS_BUILD_DIR/tests/extension-$VUE_TEMPLATE
89-
extension_workflow
89+
test_extension
9090
}
91-
export -f create_extension_workflow
91+
export -f create_extension
9292
9393
install:
9494
- yarn install --frozen-lockfile
@@ -101,16 +101,16 @@ script:
101101
export VUE_TEMPLATE=$(git --no-pager diff --name-only origin/master | grep "examples" | tail -n 1 | cut -d "/" -f 2)
102102
103103
if [[ "${VUE_TEMPLATES}" = *"$VUE_TEMPLATE"* ]]; then
104-
echo -e "\\e[1;34mRunning tests for \"$VUE_TEMPLATE\" example...\\e[0m"
104+
echo -e "\\e[1;34mRunning tests for \"$VUE_TEMPLATE\" example...\\e[0m"
105105
cd $TRAVIS_BUILD_DIR/examples/$VUE_TEMPLATE
106-
extension_workflow
106+
test_extension
107107
else
108108
echo -e "\\e[1;34mRunning tests for global project...\\e[0m"
109109
exit 0 # Actually there is nothing to tests :shrug:
110110
fi
111111
112112
exit $?
113113
else
114-
for VUE_TEMPLATE in $VUE_TEMPLATES; do create_extension_workflow $VUE_TEMPLATE; done;
114+
for VUE_TEMPLATE in $VUE_TEMPLATES; do create_extension $VUE_TEMPLATE; done;
115115
exit $?
116116
fi

meta.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ module.exports = {
2626
"type": "string",
2727
"message": "Author"
2828
},
29+
"license": {
30+
"when": "isNotTest",
31+
"type": "string",
32+
"message": "License"
33+
},
2934
"options": {
3035
"when": "isNotTest",
3136
"type": "confirm",

scenarios/full-airbnb.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "full-airbnb",
33
"description": "Extension generated with Kocal/vue-web-extension",
44
"author": "Travis",
5+
"license": "MIT",
56
"options": true,
67
"router": true,
78
"store": true,

scenarios/full.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "full",
33
"description": "Extension generated with Kocal/vue-web-extension",
44
"author": "Travis",
5+
"license": "MIT",
56
"options": true,
67
"router": true,
78
"store": true,

scenarios/minimal.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "minimal",
33
"description": "Extension generated with Kocal/vue-web-extension",
44
"author": "Travis",
5+
"license": "MIT",
56
"options": false,
67
"router": false,
78
"store": false,

template/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "{{ description }}",
55
"author": "{{ author }}",
6+
{{#if license}}"license": "{{ license }}",{{/if}}
67
"scripts": {
78
{{#lint}}
89
"lint": "eslint --ext .js,.vue src",
@@ -14,7 +15,7 @@
1415
{{#if_eq prettierHook "preciseCommits"}}
1516
"precommit": "precise-commits",
1617
{{/if_eq}}
17-
"prettier": "prettier 'src/**/*.{js,vue}'",
18+
"prettier": "prettier \"src/**/*.{js,vue}\"",
1819
"prettier:write": "npm run prettier -- --write",
1920
{{/prettier}}
2021
"build": "cross-env NODE_ENV=production webpack --hide-modules",

tests/test_axios.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
if (!(Get-Content package.json | Out-String) -like "*axios*")
4+
{
5+
throw "Axios not found in package.json"
6+
Get-Content package.json
7+
}

tests/test_options.ps1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
Test-Path src/options/options.js | Assert-True
4+
Test-Path src/options/options.html | Assert-True
5+
Test-Path src/options/App.vue | Assert-True
6+
7+
Test-Path dist/options/options.html | Assert-True
8+
Test-Path dist/options/options.js | Assert-True
9+
Test-Path dist/options/options.css | Assert-True
10+
11+
if (!(Get-Content webpack.config.js | Out-String) -like "*'options/options': './options/options.js',*")
12+
{
13+
Get-Content webpack.config.js
14+
throw "Line « 'options/options': './options/options.js', » not found in webpack.config.js"
15+
}
16+
17+
if (!(Get-Content webpack.config.js | Out-String) -like "*{ from: 'options/options.html', to: 'options/options.html' },*")
18+
{
19+
Get-Content webpack.config.js
20+
throw "Line « { from: 'options/options.html', to: 'options/options.html' }, » not found in webpack.config.js"
21+
}
22+
23+
if (!(Get-Content src/manifest.json | Out-String) -like "*""page"": ""options/options.html"",*")
24+
{
25+
Get-Content src/manifest.json
26+
throw "Options page has not been correctly registered in src/manifest.json"
27+
}

tests/test_router.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
Test-Path src/popup/router/pages/Index.vue | Assert-True
4+
Test-Path src/popup/router/index.js | Assert-True
5+
Test-Path src/popup/router/routes.js | Assert-True
6+
7+
if (!(Get-Content package.json | Out-String) -like "*vue-router*")
8+
{
9+
Get-Content package.json
10+
throw "Vue-router not found in package.json"
11+
}
12+
13+
if (!(Get-Content src/popup/popup.js | Out-String) -like "*import router from './router'*")
14+
{
15+
Get-Content src/popup/popup.js
16+
throw "Line « import router from './router' » not found in src/popup/popup.js"
17+
}
18+
19+
if (!(Get-Content src/popup/popup.js | Out-String) -like "*router,*")
20+
{
21+
Get-Content src/popup/popup.js
22+
throw "Line « router, » not found in src/popup/popup.js"
23+
}
24+

0 commit comments

Comments
 (0)