@dword-design/base-config-web-extension 2.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/dist/config.js +24 -0
- package/dist/dev.js +7 -6
- package/dist/get-manifest.js +52 -0
- package/dist/index.js +35 -30
- package/dist/lint.js +1 -1
- package/dist/prepublish-only.js +7 -11
- package/package.json +16 -16
- package/dist/config-to-manifest.js +0 -44
- package/dist/get-webpack-config.js +0 -70
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -102,5 +102,5 @@ Thanks a lot for your support! ❤️
|
|
|
102
102
|
|
|
103
103
|
## License
|
|
104
104
|
|
|
105
|
-
[MIT License](https://opensource.org/
|
|
105
|
+
[MIT License](https://opensource.org/license/mit/) © [Sebastian Landwehr](https://sebastianlandwehr.com)
|
|
106
106
|
<!-- /LICENSE -->
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import vue from '@vitejs/plugin-vue';
|
|
2
|
+
import P from 'path';
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import babel from 'vite-plugin-babel';
|
|
5
|
+
import eslint from 'vite-plugin-eslint';
|
|
6
|
+
import webExtension from 'vite-plugin-web-extension';
|
|
7
|
+
import getManifest from "./get-manifest.js";
|
|
8
|
+
process.env.TARGET = process.env.TARGET || 'chrome';
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
build: {
|
|
11
|
+
outDir: P.join('dist', process.env.TARGET)
|
|
12
|
+
},
|
|
13
|
+
plugins: [vue(), webExtension({
|
|
14
|
+
browser: process.env.TARGET,
|
|
15
|
+
manifest: () => getManifest({
|
|
16
|
+
browser: process.env.TARGET
|
|
17
|
+
}),
|
|
18
|
+
scriptViteConfig: {
|
|
19
|
+
plugins: [eslint({
|
|
20
|
+
fix: true
|
|
21
|
+
}), babel()]
|
|
22
|
+
}
|
|
23
|
+
})]
|
|
24
|
+
});
|
package/dist/dev.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { execaCommand } from 'execa';
|
|
2
|
+
export default (() => browser => execaCommand('vite', {
|
|
3
|
+
env: {
|
|
4
|
+
TARGET: browser
|
|
5
|
+
},
|
|
6
|
+
stdio: 'inherit'
|
|
7
|
+
}));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import loadPkg from 'load-pkg';
|
|
3
|
+
import { pick } from 'lodash-es';
|
|
4
|
+
export default (async ({
|
|
5
|
+
browser
|
|
6
|
+
}) => {
|
|
7
|
+
const packageConfig = await loadPkg();
|
|
8
|
+
const config = await fs.readJson('config.json').catch(() => ({}));
|
|
9
|
+
const iconExists = await fs.exists('assets/icon.png');
|
|
10
|
+
const popupExists = await fs.exists('popup.html');
|
|
11
|
+
return {
|
|
12
|
+
name: config.name,
|
|
13
|
+
...pick(packageConfig, ['version', 'description']),
|
|
14
|
+
manifest_version: 3,
|
|
15
|
+
...(iconExists && {
|
|
16
|
+
icons: {
|
|
17
|
+
128: 'assets/icon.png'
|
|
18
|
+
}
|
|
19
|
+
}),
|
|
20
|
+
...(('action' in config || popupExists) && {
|
|
21
|
+
action: {
|
|
22
|
+
...(iconExists && {
|
|
23
|
+
default_icon: 'assets/icon.png'
|
|
24
|
+
}),
|
|
25
|
+
...(popupExists && {
|
|
26
|
+
default_popup: 'popup.html'
|
|
27
|
+
}),
|
|
28
|
+
...(typeof config.action === 'object' && config.action)
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
...(((await fs.exists('content.js')) || config.css?.length > 0) && {
|
|
32
|
+
content_scripts: [{
|
|
33
|
+
js: ['content.js'],
|
|
34
|
+
...(config.css?.length > 0 && {
|
|
35
|
+
css: config.css
|
|
36
|
+
}),
|
|
37
|
+
matches: config.matches || ['<all_urls>']
|
|
38
|
+
}]
|
|
39
|
+
}),
|
|
40
|
+
...((await fs.exists('background.js')) && {
|
|
41
|
+
background: {
|
|
42
|
+
...(browser === 'firefox' ? {
|
|
43
|
+
persistent: false,
|
|
44
|
+
scripts: ['background.js']
|
|
45
|
+
} : {
|
|
46
|
+
service_worker: 'background.js'
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
...pick(config, ['host_permissions', 'optional_host_permissions', 'optional_permissions', 'permissions', 'browser_specific_settings', 'css'])
|
|
51
|
+
};
|
|
52
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import depcheckParserSass from '@dword-design/depcheck-parser-sass';
|
|
2
|
-
import endent from
|
|
2
|
+
import { endent } from '@dword-design/functions';
|
|
3
3
|
import packageName from 'depcheck-package-name';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
import outputFiles from 'output-files';
|
|
6
|
+
import P from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
6
8
|
import dev from "./dev.js";
|
|
7
9
|
import lint from "./lint.js";
|
|
8
10
|
import prepublishOnly from "./prepublish-only.js";
|
|
11
|
+
const __dirname = P.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const isInNodeModules = __dirname.split(P.sep).includes('node_modules');
|
|
13
|
+
const resolver = createRequire(import.meta.url);
|
|
9
14
|
export default (config => ({
|
|
10
|
-
allowedMatches: ['
|
|
15
|
+
allowedMatches: ['assets', 'background.js', 'content.js', 'config.json', 'icon.png', 'index.spec.js', 'options.html', 'popup.html', 'options.js', 'popup.js', 'model'],
|
|
11
16
|
commands: {
|
|
12
17
|
dev: {
|
|
13
|
-
arguments: '[
|
|
18
|
+
arguments: '[browser]',
|
|
14
19
|
handler: dev(config)
|
|
15
20
|
},
|
|
16
|
-
prepublishOnly:
|
|
17
|
-
|
|
21
|
+
prepublishOnly: {
|
|
22
|
+
arguments: '[browser]',
|
|
23
|
+
handler: prepublishOnly(config)
|
|
24
|
+
}
|
|
18
25
|
},
|
|
19
26
|
depcheckConfig: {
|
|
20
27
|
parsers: {
|
|
@@ -31,26 +38,29 @@ export default (config => ({
|
|
|
31
38
|
GOOGLE_REFRESH_TOKEN: '${{ secrets.GOOGLE_REFRESH_TOKEN }}'
|
|
32
39
|
},
|
|
33
40
|
deployPlugins: [[packageName`@semantic-release/exec`, {
|
|
34
|
-
prepareCmd:
|
|
35
|
-
}], [packageName`semantic-release-chrome`, {
|
|
36
|
-
asset: 'extension.zip',
|
|
37
|
-
extensionId: config.chromeExtensionId,
|
|
38
|
-
target: 'draft'
|
|
41
|
+
prepareCmd: `yarn prepublishOnly && yarn prepublishOnly firefox && zip -r dist/chrome dist/chrome.zip && zip -r dist/firefox dist/firefox.zip && git archive --output=dist/firefox-sources.zip HEAD && ${packageName`publish-browser-extension`} --chrome-zip=dist/chrome.zip --firefox-zip=dist/firefox.zip --firefox-sources=dist/firefox-sources.zip`
|
|
39
42
|
}]],
|
|
40
|
-
editorIgnore: ['.eslintrc.json', 'dist'],
|
|
41
|
-
gitignore: ['/.eslintrc.json', '/
|
|
43
|
+
editorIgnore: ['.eslintrc.json', 'dist', '/vite.config.js'],
|
|
44
|
+
gitignore: ['/.eslintrc.json', '/dist', '/vite.config.js'],
|
|
42
45
|
isLockFileFixCommitType: true,
|
|
43
46
|
lint,
|
|
44
|
-
prepare: () =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
prepare: () => {
|
|
48
|
+
const configPath = isInNodeModules ? '@dword-design/base-config-web-extension/config' : `./${P.relative(process.cwd(), resolver.resolve('./config.js')).split(P.sep).join('/')}`;
|
|
49
|
+
outputFiles({
|
|
50
|
+
'.eslintrc.json': `${JSON.stringify({
|
|
51
|
+
extends: packageName`@dword-design/eslint-config`
|
|
52
|
+
}, undefined, 2)}\n`,
|
|
53
|
+
'vite.config.js': endent`
|
|
54
|
+
import config from '${configPath}'
|
|
55
|
+
|
|
56
|
+
export default config
|
|
57
|
+
`
|
|
58
|
+
});
|
|
59
|
+
},
|
|
50
60
|
readmeInstallString: endent`
|
|
51
61
|
## Recommended setup
|
|
52
|
-
* Node.js
|
|
53
|
-
* Yarn 1.
|
|
62
|
+
* Node.js 20.11.1
|
|
63
|
+
* Yarn 1.22.19
|
|
54
64
|
|
|
55
65
|
## Install
|
|
56
66
|
\`\`\`bash
|
|
@@ -59,18 +69,13 @@ export default (config => ({
|
|
|
59
69
|
|
|
60
70
|
## Running a development server
|
|
61
71
|
\`\`\`bash
|
|
62
|
-
$ yarn dev [
|
|
72
|
+
$ yarn dev [browser]
|
|
63
73
|
\`\`\`
|
|
64
|
-
Available
|
|
74
|
+
Available browsers are \`firefox\` and \`chrome\`. Default is \`firefox\`.
|
|
65
75
|
|
|
66
76
|
## Building the extension for upload
|
|
67
77
|
\`\`\`bash
|
|
68
|
-
$ yarn prepublishOnly
|
|
69
|
-
\`\`\`
|
|
70
|
-
|
|
71
|
-
## Archiving the source for upload
|
|
72
|
-
\`\`\`bash
|
|
73
|
-
$ yarn source
|
|
78
|
+
$ yarn prepublishOnly [browser]
|
|
74
79
|
\`\`\`
|
|
75
80
|
`
|
|
76
81
|
}));
|
package/dist/lint.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execaCommand } from 'execa';
|
|
2
2
|
export default (async () => {
|
|
3
3
|
try {
|
|
4
|
-
await execaCommand('eslint --fix --ext .js,.json --ignore-path .gitignore .', {
|
|
4
|
+
await execaCommand('eslint --fix --ext .js,.json,.vue --ignore-path .gitignore .', {
|
|
5
5
|
all: true
|
|
6
6
|
});
|
|
7
7
|
} catch (error) {
|
package/dist/prepublish-only.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return reject(new Error(JSON.stringify(stats.toJson().errors, undefined, 2)));
|
|
9
|
-
}
|
|
10
|
-
return resolve();
|
|
11
|
-
})));
|
|
1
|
+
import { execaCommand } from 'execa';
|
|
2
|
+
export default (() => browser => execaCommand('vite build', {
|
|
3
|
+
env: {
|
|
4
|
+
TARGET: browser
|
|
5
|
+
},
|
|
6
|
+
stdio: 'inherit'
|
|
7
|
+
}));
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dword-design/base-config-web-extension",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"repository": "dword-design/base-config-web-extension",
|
|
5
5
|
"funding": "https://github.com/sponsors/dword-design",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Sebastian Landwehr <info@sebastianlandwehr.com>",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"exports":
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./config": "./dist/config.js"
|
|
12
|
+
},
|
|
10
13
|
"main": "dist/index.js",
|
|
11
14
|
"files": [
|
|
12
15
|
"dist"
|
|
@@ -25,24 +28,21 @@
|
|
|
25
28
|
"dependencies": {
|
|
26
29
|
"@dword-design/depcheck-parser-sass": "^4.0.4",
|
|
27
30
|
"@dword-design/eslint-config": "^5.0.1",
|
|
28
|
-
"@dword-design/functions": "^
|
|
31
|
+
"@dword-design/functions": "^6.0.0",
|
|
29
32
|
"@semantic-release/exec": "^6.0.3",
|
|
30
|
-
"
|
|
31
|
-
"better-node-env": "^1.0.3",
|
|
32
|
-
"copy-webpack-plugin": "^12.0.2",
|
|
33
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
33
34
|
"depcheck-package-name": "^3.0.1",
|
|
34
|
-
"eslint-webpack-plugin": "^4.0.1",
|
|
35
35
|
"execa": "^8.0.1",
|
|
36
36
|
"fs-extra": "^11.1.0",
|
|
37
37
|
"load-pkg": "^4.0.0",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
38
|
+
"lodash-es": "^4.17.21",
|
|
39
|
+
"output-files": "^2.0.0",
|
|
40
|
+
"publish-browser-extension": "^2.1.3",
|
|
41
|
+
"vite": "^5.1.4",
|
|
42
|
+
"vite-plugin-babel": "^1.2.0",
|
|
43
|
+
"vite-plugin-eslint": "^1.8.1",
|
|
44
|
+
"vite-plugin-web-extension": "^4.1.1",
|
|
45
|
+
"vue": "^3.4.21"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@dword-design/base": "^11.0.2",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@dword-design/tester-plugin-tmp-dir": "^2.0.3",
|
|
52
52
|
"express": "^4.17.1",
|
|
53
53
|
"globby": "^14.0.0",
|
|
54
|
-
"
|
|
54
|
+
"webextension-polyfill": "^0.10.0",
|
|
55
55
|
"with-local-tmp-dir": "^5.0.1",
|
|
56
56
|
"xvfb": "^0.4.0"
|
|
57
57
|
},
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import pick from "@dword-design/functions/dist/pick.js";
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import loadPkg from 'load-pkg';
|
|
4
|
-
export default (async configString => {
|
|
5
|
-
var _packageConfig, _config;
|
|
6
|
-
const packageConfig = await loadPkg();
|
|
7
|
-
const config = JSON.parse(configString);
|
|
8
|
-
const iconExists = fs.existsSync('assets/icon.png');
|
|
9
|
-
const popupExists = fs.existsSync('popup.html');
|
|
10
|
-
return JSON.stringify({
|
|
11
|
-
name: config.name,
|
|
12
|
-
...(_packageConfig = packageConfig, pick(['version', 'description'])(_packageConfig)),
|
|
13
|
-
manifest_version: 2,
|
|
14
|
-
...(iconExists && {
|
|
15
|
-
icons: {
|
|
16
|
-
128: 'assets/icon.png'
|
|
17
|
-
}
|
|
18
|
-
}),
|
|
19
|
-
...(('browser_action' in config || popupExists) && {
|
|
20
|
-
browser_action: {
|
|
21
|
-
...(iconExists && {
|
|
22
|
-
default_icon: 'assets/icon.png'
|
|
23
|
-
}),
|
|
24
|
-
...(popupExists && {
|
|
25
|
-
default_popup: 'popup.html'
|
|
26
|
-
}),
|
|
27
|
-
...(typeof config.browser_action === 'object' && config.browser_action)
|
|
28
|
-
}
|
|
29
|
-
}),
|
|
30
|
-
...(fs.existsSync('content.js') && {
|
|
31
|
-
content_scripts: [{
|
|
32
|
-
js: ['browser-polyfill.js', 'content.js'],
|
|
33
|
-
matches: config.matches || ['<all_urls>']
|
|
34
|
-
}]
|
|
35
|
-
}),
|
|
36
|
-
...(fs.existsSync('background.js') && {
|
|
37
|
-
background: {
|
|
38
|
-
persistent: false,
|
|
39
|
-
scripts: ['browser-polyfill.js', 'background.js']
|
|
40
|
-
}
|
|
41
|
-
}),
|
|
42
|
-
...(_config = config, pick(['permissions', 'browser_specific_settings'])(_config))
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import nodeEnv from 'better-node-env';
|
|
2
|
-
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
|
3
|
-
import packageName from 'depcheck-package-name';
|
|
4
|
-
import EslintWebpackPlugin from 'eslint-webpack-plugin';
|
|
5
|
-
import fs from 'fs-extra';
|
|
6
|
-
import { WebExtWebpackPlugin } from 'webext-webpack-plugin';
|
|
7
|
-
import WebpackBar from 'webpackbar';
|
|
8
|
-
import configToManifest from "./config-to-manifest.js";
|
|
9
|
-
export default (config => ({
|
|
10
|
-
devtool: false,
|
|
11
|
-
entry: {
|
|
12
|
-
...(fs.existsSync('background.js') && {
|
|
13
|
-
background: './background.js'
|
|
14
|
-
}),
|
|
15
|
-
...(fs.existsSync('content.js') && {
|
|
16
|
-
content: './content.js'
|
|
17
|
-
}),
|
|
18
|
-
...(fs.existsSync('options.js') && {
|
|
19
|
-
options: './options.js'
|
|
20
|
-
}),
|
|
21
|
-
...(fs.existsSync('popup.js') && {
|
|
22
|
-
popup: './popup.js'
|
|
23
|
-
})
|
|
24
|
-
},
|
|
25
|
-
mode: nodeEnv === 'production' ? nodeEnv : 'development',
|
|
26
|
-
module: {
|
|
27
|
-
rules: [{
|
|
28
|
-
test: /\.js$/,
|
|
29
|
-
use: {
|
|
30
|
-
loader: packageName`babel-loader`
|
|
31
|
-
}
|
|
32
|
-
}, {
|
|
33
|
-
test: /\.s[ac]ss$/i,
|
|
34
|
-
use: [packageName`raw-loader`, packageName`sass-loader`]
|
|
35
|
-
}]
|
|
36
|
-
},
|
|
37
|
-
output: {
|
|
38
|
-
clean: true
|
|
39
|
-
},
|
|
40
|
-
plugins: [new EslintWebpackPlugin({
|
|
41
|
-
failOnWarning: true,
|
|
42
|
-
fix: true
|
|
43
|
-
}), new WebpackBar(), new CopyWebpackPlugin({
|
|
44
|
-
patterns: [{
|
|
45
|
-
from: 'config.json',
|
|
46
|
-
to: 'manifest.json',
|
|
47
|
-
transform: configToManifest
|
|
48
|
-
}, {
|
|
49
|
-
from: require.resolve('webextension-polyfill')
|
|
50
|
-
}, {
|
|
51
|
-
from: 'assets',
|
|
52
|
-
noErrorOnMissing: true,
|
|
53
|
-
to: 'assets'
|
|
54
|
-
}, {
|
|
55
|
-
from: 'options.html',
|
|
56
|
-
noErrorOnMissing: true
|
|
57
|
-
}, {
|
|
58
|
-
from: 'popup.html',
|
|
59
|
-
noErrorOnMissing: true
|
|
60
|
-
}]
|
|
61
|
-
}), new WebExtWebpackPlugin({
|
|
62
|
-
build: {
|
|
63
|
-
artifactsDir: 'artifacts'
|
|
64
|
-
},
|
|
65
|
-
run: {
|
|
66
|
-
startUrl: config.startUrl,
|
|
67
|
-
target: process.env.WEB_EXT_TARGET
|
|
68
|
-
}
|
|
69
|
-
})]
|
|
70
|
-
}));
|