Skip to content

Commit 2f6e5e0

Browse files
committed
Ran formatter over codebase
1 parent e5cdd75 commit 2f6e5e0

File tree

10 files changed

+178
-160
lines changed

10 files changed

+178
-160
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
generator/template/background/src/background.js

.eslintrc.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ module.exports = {
33
env: {
44
node: true
55
},
6-
'extends': [
7-
'plugin:vue/essential',
8-
'@vue/standard'
9-
],
6+
extends: ['plugin:vue/essential', '@vue/standard'],
107
rules: {
118
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
129
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
13-
},
10+
}
1411
}

generator/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ module.exports = (api, _options) => {
3030
const pkg = {
3131
private: true,
3232
scripts: {
33-
'serve': 'vue-cli-service build --mode development --watch'
33+
serve: 'vue-cli-service build --mode development --watch'
3434
},
3535
dependencies: {
3636
'vue-router': '^3.0.1',
37-
'vuex': '^3.0.1'
37+
vuex: '^3.0.1'
3838
},
3939
vue: {
4040
pages: {},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as types from './mutation-types'
22

3-
export const setFoo = ({commit}, payload) => {
3+
export const setFoo = ({ commit }, payload) => {
44
commit(types.UPDATE_FOO, payload)
55
}

index.js

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ const defaultOptions = {
1212
modesToZip: ['production']
1313
}
1414
const performanceAssetFilterList = [
15-
(file) => !(/\.map$/.test(file)),
15+
(file) => !/\.map$/.test(file),
1616
(file) => !file.endsWith('.zip'),
17-
(file) => !(/^icons\//.test(file))
17+
(file) => !/^icons\//.test(file)
1818
]
1919

2020
module.exports = (api, options) => {
2121
const appRootPath = api.getCwd()
22-
const pluginOptions = options.pluginOptions.browserExtension ? Object.assign(defaultOptions, options.pluginOptions.browserExtension) : defaultOptions
22+
const pluginOptions = options.pluginOptions.browserExtension
23+
? Object.assign(defaultOptions, options.pluginOptions.browserExtension)
24+
: defaultOptions
2325
const componentOptions = pluginOptions.componentOptions
2426
const packageJson = require(path.join(appRootPath, 'package.json'))
25-
const isDevelopment = api.service.mode === 'development'
2627
const isProduction = api.service.mode === 'production'
2728
const keyFile = api.resolve('key.pem')
2829
const hasKeyFile = fs.existsSync(keyFile)
@@ -40,10 +41,10 @@ module.exports = (api, options) => {
4041
if (!Array.isArray(paths)) {
4142
paths = [paths]
4243
}
43-
entry[name] = paths.map(path => api.resolve(path))
44+
entry[name] = paths.map((path) => api.resolve(path))
4445
}
4546
}
46-
webpackConfig.merge({entry})
47+
webpackConfig.merge({ entry })
4748
webpackConfig.optimization.delete('splitChunks')
4849
})
4950

@@ -55,16 +56,19 @@ module.exports = (api, options) => {
5556
if (webpackConfig.performance === undefined) {
5657
webpackConfig.performance = {}
5758
}
58-
webpackConfig.performance.assetFilter = (assetFilename) => performanceAssetFilterList.every((filter) => filter(assetFilename))
59+
webpackConfig.performance.assetFilter = (assetFilename) =>
60+
performanceAssetFilterList.every((filter) => filter(assetFilename))
5961

6062
if (pluginOptions.autoImportPolyfill) {
61-
webpackConfig.plugins.push(new webpack.ProvidePlugin({
62-
'browser': 'webextension-polyfill'
63-
}))
63+
webpackConfig.plugins.push(
64+
new webpack.ProvidePlugin({
65+
browser: 'webextension-polyfill'
66+
})
67+
)
6468

6569
// Workaround for https://github.com/mozilla/webextension-polyfill/issues/68
6670
webpackConfig.module.rules.push({
67-
test: require.resolve('webextension-polyfill', {paths: [appRootPath]}),
71+
test: require.resolve('webextension-polyfill', { paths: [appRootPath] }),
6872
use: 'imports-loader?browser=>undefined'
6973
})
7074
}
@@ -77,50 +81,59 @@ module.exports = (api, options) => {
7781
}
7882
}
7983

80-
webpackConfig.plugins.push(new CopyWebpackPlugin([{
81-
from: './src/manifest.json',
82-
to: 'manifest.json',
83-
transform: (content) => {
84-
return new Promise((resolve, reject) => {
85-
const jsonContent = JSON.parse(content)
86-
if (pluginOptions.manifestSync.includes('version')) {
87-
jsonContent.version = packageJson.version
88-
}
89-
if (pluginOptions.manifestSync.includes('description')) {
90-
jsonContent.description = packageJson.description
91-
}
92-
93-
if (isProduction) {
94-
return resolve(JSON.stringify(jsonContent, null, 2))
95-
}
96-
97-
jsonContent.content_security_policy = jsonContent.content_security_policy || "script-src 'self' 'unsafe-eval'; object-src 'self'"
98-
99-
try {
100-
fs.statSync(keyFile)
84+
webpackConfig.plugins.push(
85+
new CopyWebpackPlugin([
86+
{
87+
from: './src/manifest.json',
88+
to: 'manifest.json',
89+
transform: (content) => {
90+
return new Promise((resolve, reject) => {
91+
const jsonContent = JSON.parse(content)
92+
if (pluginOptions.manifestSync.includes('version')) {
93+
jsonContent.version = packageJson.version
94+
}
95+
if (pluginOptions.manifestSync.includes('description')) {
96+
jsonContent.description = packageJson.description
97+
}
10198

102-
return exec(`openssl rsa -in ${keyFile} -pubout -outform DER | openssl base64 -A`, (error, stdout) => {
103-
if (error) {
104-
// node couldn't execute the command
105-
reject(error)
99+
if (isProduction) {
100+
return resolve(JSON.stringify(jsonContent, null, 2))
106101
}
107102

108-
jsonContent.key = stdout
109-
resolve(JSON.stringify(jsonContent, null, 2))
103+
jsonContent.content_security_policy =
104+
jsonContent.content_security_policy || "script-src 'self' 'unsafe-eval'; object-src 'self'"
105+
106+
try {
107+
fs.statSync(keyFile)
108+
109+
return exec(`openssl rsa -in ${keyFile} -pubout -outform DER | openssl base64 -A`, (error, stdout) => {
110+
if (error) {
111+
// node couldn't execute the command
112+
reject(error)
113+
}
114+
115+
jsonContent.key = stdout
116+
resolve(JSON.stringify(jsonContent, null, 2))
117+
})
118+
} catch (error) {
119+
logger.warn(
120+
'No key.pem file found. This is fine for dev, however you may have problems publishing without one'
121+
)
122+
resolve(JSON.stringify(jsonContent, null, 2))
123+
}
110124
})
111-
} catch (error) {
112-
logger.warn('No key.pem file found. This is fine for dev, however you may have problems publishing without one')
113-
resolve(JSON.stringify(jsonContent, null, 2))
114125
}
115-
})
116-
}
117-
}]))
126+
}
127+
])
128+
)
118129

119130
if (pluginOptions.modesToZip.includes(api.service.mode)) {
120-
webpackConfig.plugins.push(new ZipPlugin({
121-
path: api.resolve(`${options.outputDir || 'dist'}-zip`),
122-
filename: `${packageJson.name}-v${packageJson.version}-${api.service.mode}.zip`
123-
}))
131+
webpackConfig.plugins.push(
132+
new ZipPlugin({
133+
path: api.resolve(`${options.outputDir || 'dist'}-zip`),
134+
filename: `${packageJson.name}-v${packageJson.version}-${api.service.mode}.zip`
135+
})
136+
)
124137
}
125138

126139
// configure webpack-extension-reloader for automatic reloading of extension when content and background scripts change (not HMR)

locales/en.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"com": {
3-
"rewardstyle": {
4-
"browserExt": {
5-
"tasks": {
6-
"extServe": {
7-
"description": "Builds and watches the project, writing the files to the output directory"
8-
}
9-
}
10-
}
2+
"com": {
3+
"adambullmer": {
4+
"browserExt": {
5+
"tasks": {
6+
"extServe": {
7+
"description": "Builds and watches the project, writing the files to the output directory"
8+
}
119
}
10+
}
1211
}
12+
}
1313
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"repository": "git@github.com:adambullmer/vue-cli-plugin-browser-extension.git",
2020
"author": "Adam Bullmer <psycodrumfreak@gmail.com>",
2121
"devDependencies": {
22-
"@vue/eslint-config-standard": "^3.0.0-rc.3",
22+
"@vue/eslint-config-standard": "^3.0.0",
2323
"eslint": "^5.1.0",
2424
"eslint-plugin-vue": "^4.5.0"
2525
},

prompts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ module.exports = [
7474
type: 'confirm',
7575
message: 'Add WebExtension polyfill?',
7676
default: true,
77-
when: answers => answers.api === 'browser'
77+
when: (answers) => answers.api === 'browser'
7878
},
7979
{
8080
name: 'autoImportPolyfill',
8181
type: 'confirm',
8282
message: 'Make polyfill available without import?',
8383
default: true,
84-
when: answers => answers.usePolyfill
84+
when: (answers) => answers.usePolyfill
8585
}
8686
]

ui.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = (api) => {
22
api.describeTask({
33
match: /vue-cli-service ext-serve/,
4-
description: 'com.rewardstyle.browserExt.tasks.extServe.description',
5-
link: 'https://github.com/rewardstyle/linkninjax-ext'
4+
description: 'com.adambullmer.browserExt.tasks.extServe.description',
5+
link: 'https://github.com/adambullmer/vue-cli-browser-extension'
66
})
77
}

0 commit comments

Comments
 (0)