@dword-design/base-config-web-extension 1.10.35 → 3.0.0

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 CHANGED
@@ -6,7 +6,7 @@ Copyright &copy; Sebastian Landwehr <info@sebastianlandwehr.com>
6
6
 
7
7
  and licensed under:
8
8
 
9
- [MIT License](https://opensource.org/licenses/MIT)
9
+ [MIT License](https://opensource.org/license/mit/)
10
10
 
11
11
  ## MIT License
12
12
 
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/licenses/MIT) © [Sebastian Landwehr](https://sebastianlandwehr.com)
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,20 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _execa = _interopRequireDefault(require("execa"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- var _default = (target = 'firefox-desktop') => (0, _execa.default)('webpack-cli', ['--watch', '--config', require.resolve("./webpack.config")], {
1
+ import { execaCommand } from 'execa';
2
+ export default (() => browser => execaCommand('vite', {
13
3
  env: {
14
- WEB_EXT_TARGET: target
4
+ TARGET: browser
15
5
  },
16
6
  stdio: 'inherit'
17
- });
18
-
19
- exports.default = _default;
20
- module.exports = exports.default;
7
+ }));
@@ -0,0 +1,53 @@
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
+ var _config$css, _config$css2;
8
+ const packageConfig = await loadPkg();
9
+ const config = await fs.readJson('config.json').catch(() => ({}));
10
+ const iconExists = await fs.exists('assets/icon.png');
11
+ const popupExists = await fs.exists('popup.html');
12
+ return {
13
+ name: config.name,
14
+ ...pick(packageConfig, ['version', 'description']),
15
+ manifest_version: 3,
16
+ ...(iconExists && {
17
+ icons: {
18
+ 128: 'assets/icon.png'
19
+ }
20
+ }),
21
+ ...(('action' in config || popupExists) && {
22
+ action: {
23
+ ...(iconExists && {
24
+ default_icon: 'assets/icon.png'
25
+ }),
26
+ ...(popupExists && {
27
+ default_popup: 'popup.html'
28
+ }),
29
+ ...(typeof config.action === 'object' && config.action)
30
+ }
31
+ }),
32
+ ...(((await fs.exists('content.js')) || ((_config$css = config.css) === null || _config$css === void 0 ? void 0 : _config$css.length) > 0) && {
33
+ content_scripts: [{
34
+ js: ['content.js'],
35
+ ...(((_config$css2 = config.css) === null || _config$css2 === void 0 ? void 0 : _config$css2.length) > 0 && {
36
+ css: config.css
37
+ }),
38
+ matches: config.matches || ['<all_urls>']
39
+ }]
40
+ }),
41
+ ...((await fs.exists('background.js')) && {
42
+ background: {
43
+ ...(browser === 'firefox' ? {
44
+ persistent: false,
45
+ scripts: ['background.js']
46
+ } : {
47
+ service_worker: 'background.js'
48
+ })
49
+ }
50
+ }),
51
+ ...pick(config, ['permissions', 'browser_specific_settings', 'css'])
52
+ };
53
+ });
package/dist/index.js CHANGED
@@ -1,43 +1,31 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _depcheckParserSass = _interopRequireDefault(require("@dword-design/depcheck-parser-sass"));
9
-
10
- var _endent = _interopRequireDefault(require("@dword-design/functions/dist/endent"));
11
-
12
- var _depcheckPackageName = _interopRequireDefault(require("depcheck-package-name"));
13
-
14
- var _execa = _interopRequireDefault(require("execa"));
15
-
16
- var _fsExtra = require("fs-extra");
17
-
18
- var _baseConfig = _interopRequireDefault(require("./base-config"));
19
-
20
- var _dev = _interopRequireDefault(require("./dev"));
21
-
22
- var _lint = _interopRequireDefault(require("./lint"));
23
-
24
- var _prepublishOnly = _interopRequireDefault(require("./prepublish-only"));
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- var _default = {
29
- allowedMatches: ['artifacts', 'assets', 'background.js', 'content.js', 'config.json', 'icon.png', 'index.spec.js', 'options.html', 'popup.html', 'options.js', 'popup.js', 'model'],
1
+ import depcheckParserSass from '@dword-design/depcheck-parser-sass';
2
+ import endent from "@dword-design/functions/dist/endent.js";
3
+ import packageName from 'depcheck-package-name';
4
+ import { createRequire } from 'module';
5
+ import outputFiles from 'output-files';
6
+ import P from 'path';
7
+ import { fileURLToPath } from 'url';
8
+ import dev from "./dev.js";
9
+ import lint from "./lint.js";
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);
14
+ export default (config => ({
15
+ allowedMatches: ['assets', 'background.js', 'content.js', 'config.json', 'icon.png', 'index.spec.js', 'options.html', 'popup.html', 'options.js', 'popup.js', 'model'],
30
16
  commands: {
31
17
  dev: {
32
- arguments: '[target]',
33
- handler: _dev.default
18
+ arguments: '[browser]',
19
+ handler: dev(config)
34
20
  },
35
- prepublishOnly: _prepublishOnly.default,
36
- source: () => _execa.default.command('git archive --output=source.zip HEAD')
21
+ prepublishOnly: {
22
+ arguments: '[browser]',
23
+ handler: prepublishOnly(config)
24
+ }
37
25
  },
38
26
  depcheckConfig: {
39
27
  parsers: {
40
- '**/*.scss': _depcheckParserSass.default
28
+ '**/*.scss': depcheckParserSass
41
29
  }
42
30
  },
43
31
  deployAssets: [{
@@ -49,27 +37,30 @@ var _default = {
49
37
  GOOGLE_CLIENT_SECRET: '${{ secrets.GOOGLE_CLIENT_SECRET }}',
50
38
  GOOGLE_REFRESH_TOKEN: '${{ secrets.GOOGLE_REFRESH_TOKEN }}'
51
39
  },
52
- deployPlugins: [[(0, _depcheckPackageName.default)`@semantic-release/exec`, {
53
- prepareCmd: 'yarn prepublishOnly'
54
- }], [(0, _depcheckPackageName.default)`semantic-release-chrome`, {
55
- asset: 'extension.zip',
56
- extensionId: _baseConfig.default.chromeExtensionId,
57
- target: 'draft'
40
+ deployPlugins: [[packageName`@semantic-release/exec`, {
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`
58
42
  }]],
59
43
  editorIgnore: ['.eslintrc.json', 'dist'],
60
- gitignore: ['/.eslintrc.json', '/artifacts', '/dist', 'source.zip'],
44
+ gitignore: ['/.eslintrc.json', '/dist'],
61
45
  isLockFileFixCommitType: true,
62
- lint: _lint.default,
63
- prepare: () => (0, _fsExtra.outputFile)('.eslintrc.json', JSON.stringify({
64
- extends: (0, _depcheckPackageName.default)`@dword-design/eslint-config`,
65
- globals: {
66
- browser: 'readonly'
67
- }
68
- }, undefined, 2)),
69
- readmeInstallString: (0, _endent.default)`
46
+ lint,
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
+ },
60
+ readmeInstallString: endent`
70
61
  ## Recommended setup
71
- * Node.js 12.16.0
72
- * Yarn 1.21.1
62
+ * Node.js 20.11.1
63
+ * Yarn 1.22.19
73
64
 
74
65
  ## Install
75
66
  \`\`\`bash
@@ -78,20 +69,13 @@ var _default = {
78
69
 
79
70
  ## Running a development server
80
71
  \`\`\`bash
81
- $ yarn dev [target]
72
+ $ yarn dev [browser]
82
73
  \`\`\`
83
- Available targets are \`firefox\` and \`chrome\`. Default is \`firefox\`.
74
+ Available browsers are \`firefox\` and \`chrome\`. Default is \`firefox\`.
84
75
 
85
76
  ## Building the extension for upload
86
77
  \`\`\`bash
87
- $ yarn prepublishOnly
88
- \`\`\`
89
-
90
- ## Archiving the source for upload
91
- \`\`\`bash
92
- $ yarn source
78
+ $ yarn prepublishOnly [browser]
93
79
  \`\`\`
94
80
  `
95
- };
96
- exports.default = _default;
97
- module.exports = exports.default;
81
+ }));
package/dist/lint.js CHANGED
@@ -1,23 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _execa = _interopRequireDefault(require("execa"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- var _default = async () => {
1
+ import { execaCommand } from 'execa';
2
+ export default (async () => {
13
3
  try {
14
- await _execa.default.command('eslint --fix --ext .js,.json --ignore-path .gitignore .', {
4
+ await execaCommand('eslint --fix --ext .js,.json,.vue --ignore-path .gitignore .', {
15
5
  all: true
16
6
  });
17
7
  } catch (error) {
18
8
  throw new Error(error.all);
19
9
  }
20
- };
21
-
22
- exports.default = _default;
23
- module.exports = exports.default;
10
+ });
@@ -1,17 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _execa = _interopRequireDefault(require("execa"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
- var _default = () => (0, _execa.default)('webpack-cli', ['--config', require.resolve("./webpack.config")], {
1
+ import { execaCommand } from 'execa';
2
+ export default (() => browser => execaCommand('vite build', {
3
+ env: {
4
+ TARGET: browser
5
+ },
13
6
  stdio: 'inherit'
14
- });
15
-
16
- exports.default = _default;
17
- module.exports = exports.default;
7
+ }));
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@dword-design/base-config-web-extension",
3
- "version": "1.10.35",
3
+ "version": "3.0.0",
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
+ "type": "module",
9
+ "exports": {
10
+ ".": "./dist/index.js",
11
+ "./config": "./dist/config.js"
12
+ },
8
13
  "main": "dist/index.js",
9
14
  "files": [
10
15
  "dist"
@@ -12,6 +17,7 @@
12
17
  "scripts": {
13
18
  "checkUnknownFiles": "base checkUnknownFiles",
14
19
  "commit": "base commit",
20
+ "depcheck": "base depcheck",
15
21
  "dev": "base dev",
16
22
  "lint": "base lint",
17
23
  "prepare": "base prepare",
@@ -20,47 +26,39 @@
20
26
  "test:raw": "base test:raw"
21
27
  },
22
28
  "dependencies": {
23
- "@dword-design/depcheck-parser-sass": "^2.0.0",
24
- "@dword-design/eslint-config": "^2.0.0",
25
- "@dword-design/functions": "^4.0.0",
26
- "@semantic-release/exec": "^5.0.0",
27
- "babel-loader": "^8.0.6",
28
- "better-node-env": "^1.0.3",
29
- "copy-webpack-plugin": "^9.0.0",
30
- "depcheck-package-name": "^2.0.0",
31
- "eslint-webpack-plugin": "^2.5.4",
32
- "execa": "^5.0.0",
33
- "fs-extra": "^10.0.0",
29
+ "@dword-design/depcheck-parser-sass": "^4.0.4",
30
+ "@dword-design/eslint-config": "^5.0.1",
31
+ "@dword-design/functions": "^5.0.27",
32
+ "@semantic-release/exec": "^6.0.3",
33
+ "@vitejs/plugin-vue": "^5.0.4",
34
+ "depcheck-package-name": "^3.0.1",
35
+ "execa": "^8.0.1",
36
+ "fs-extra": "^11.1.0",
34
37
  "load-pkg": "^4.0.0",
35
- "node-sass": "^6.0.0",
36
- "raw-loader": "^4.0.1",
37
- "sass-loader": "^12.0.0",
38
- "semantic-release-chrome": "dword-design/semantic-release-chrome#fork",
39
- "webext-webpack-plugin": "^0.0.11",
40
- "webextension-polyfill": "^0.8.0",
41
- "webpack": "^5.33.2",
42
- "webpack-cli": "^4.0.0",
43
- "webpackbar": "^4.0.0"
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"
44
46
  },
45
47
  "devDependencies": {
46
- "@dword-design/base": "^8.0.0",
47
- "@dword-design/puppeteer": "^5.0.2",
48
+ "@dword-design/base": "^11.0.2",
49
+ "@dword-design/puppeteer": "^7.0.0",
48
50
  "@dword-design/tester": "^2.0.4",
49
51
  "@dword-design/tester-plugin-tmp-dir": "^2.0.3",
50
52
  "express": "^4.17.1",
51
- "globby": "^11.0.1",
52
- "output-files": "^2.0.0",
53
- "stealthy-require-no-leak": "^1.0.2",
54
- "with-local-tmp-dir": "^4.0.0",
53
+ "globby": "^14.0.0",
54
+ "webextension-polyfill": "^0.10.0",
55
+ "with-local-tmp-dir": "^5.0.1",
55
56
  "xvfb": "^0.4.0"
56
57
  },
57
58
  "engines": {
58
- "node": ">=12"
59
+ "node": ">=18"
59
60
  },
60
61
  "publishConfig": {
61
62
  "access": "public"
62
- },
63
- "baseConfig": {
64
- "testInContainer": true
65
63
  }
66
64
  }
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _loadPkg = _interopRequireDefault(require("load-pkg"));
9
-
10
- var _loadPkg$sync;
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- const baseConfig = (_loadPkg$sync = _loadPkg.default.sync()) === null || _loadPkg$sync === void 0 ? void 0 : _loadPkg$sync.baseConfig;
15
-
16
- var _default = typeof baseConfig === 'string' ? {} : baseConfig;
17
-
18
- exports.default = _default;
19
- module.exports = exports.default;
@@ -1,59 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _pick = _interopRequireDefault(require("@dword-design/functions/dist/pick"));
9
-
10
- var _fsExtra = require("fs-extra");
11
-
12
- var _loadPkg = _interopRequireDefault(require("load-pkg"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- var _default = async configString => {
17
- var _packageConfig, _config;
18
-
19
- const packageConfig = await (0, _loadPkg.default)();
20
- const config = JSON.parse(configString);
21
- const iconExists = (0, _fsExtra.existsSync)('assets/icon.png');
22
- const popupExists = (0, _fsExtra.existsSync)('popup.html');
23
- return JSON.stringify({
24
- name: config.name,
25
- ...(_packageConfig = packageConfig, (0, _pick.default)(['version', 'description'])(_packageConfig)),
26
- manifest_version: 2,
27
- ...(iconExists && {
28
- icons: {
29
- 128: 'assets/icon.png'
30
- }
31
- }),
32
- ...(('browser_action' in config || popupExists) && {
33
- browser_action: { ...(iconExists && {
34
- default_icon: 'assets/icon.png'
35
- }),
36
- ...(popupExists && {
37
- default_popup: 'popup.html'
38
- }),
39
- ...(typeof config.browser_action === 'object' && config.browser_action)
40
- }
41
- }),
42
- ...((0, _fsExtra.existsSync)('content.js') && {
43
- content_scripts: [{
44
- js: ['browser-polyfill.js', 'content.js'],
45
- matches: config.matches || ['<all_urls>']
46
- }]
47
- }),
48
- ...((0, _fsExtra.existsSync)('background.js') && {
49
- background: {
50
- persistent: false,
51
- scripts: ['browser-polyfill.js', 'background.js']
52
- }
53
- }),
54
- ...(_config = config, (0, _pick.default)(['permissions', 'browser_specific_settings'])(_config))
55
- });
56
- };
57
-
58
- exports.default = _default;
59
- module.exports = exports.default;
@@ -1,90 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _betterNodeEnv = _interopRequireDefault(require("better-node-env"));
9
-
10
- var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
11
-
12
- var _depcheckPackageName = _interopRequireDefault(require("depcheck-package-name"));
13
-
14
- var _eslintWebpackPlugin = _interopRequireDefault(require("eslint-webpack-plugin"));
15
-
16
- var _fsExtra = require("fs-extra");
17
-
18
- var _webextWebpackPlugin = require("webext-webpack-plugin");
19
-
20
- var _webpackbar = _interopRequireDefault(require("webpackbar"));
21
-
22
- var _baseConfig = _interopRequireDefault(require("./base-config"));
23
-
24
- var _configToManifest = _interopRequireDefault(require("./config-to-manifest"));
25
-
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
- var _default = {
29
- devtool: false,
30
- entry: { ...((0, _fsExtra.existsSync)('background.js') && {
31
- background: './background.js'
32
- }),
33
- ...((0, _fsExtra.existsSync)('content.js') && {
34
- content: './content.js'
35
- }),
36
- ...((0, _fsExtra.existsSync)('options.js') && {
37
- options: './options.js'
38
- }),
39
- ...((0, _fsExtra.existsSync)('popup.js') && {
40
- popup: './popup.js'
41
- })
42
- },
43
- mode: _betterNodeEnv.default === 'production' ? _betterNodeEnv.default : 'development',
44
- module: {
45
- rules: [{
46
- test: /\.js$/,
47
- use: {
48
- loader: (0, _depcheckPackageName.default)`babel-loader`
49
- }
50
- }, {
51
- test: /\.s[ac]ss$/i,
52
- use: [(0, _depcheckPackageName.default)`raw-loader`, (0, _depcheckPackageName.default)`sass-loader`]
53
- }]
54
- },
55
- output: {
56
- clean: true
57
- },
58
- plugins: [new _eslintWebpackPlugin.default({
59
- failOnWarning: true,
60
- fix: true
61
- }), new _webpackbar.default(), new _copyWebpackPlugin.default({
62
- patterns: [{
63
- from: 'config.json',
64
- to: 'manifest.json',
65
- transform: _configToManifest.default
66
- }, {
67
- from: require.resolve('webextension-polyfill')
68
- }, {
69
- from: 'assets',
70
- noErrorOnMissing: true,
71
- to: 'assets'
72
- }, {
73
- from: 'options.html',
74
- noErrorOnMissing: true
75
- }, {
76
- from: 'popup.html',
77
- noErrorOnMissing: true
78
- }]
79
- }), new _webextWebpackPlugin.WebExtWebpackPlugin({
80
- build: {
81
- artifactsDir: 'artifacts'
82
- },
83
- run: {
84
- startUrl: _baseConfig.default.startUrl,
85
- target: process.env.WEB_EXT_TARGET
86
- }
87
- })]
88
- };
89
- exports.default = _default;
90
- module.exports = exports.default;