@dword-design/base-config-web-extension 3.1.6 → 3.1.8

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
@@ -14,8 +14,17 @@ MIT License
14
14
 
15
15
  Copyright (c) <year> <copyright holders>
16
16
 
17
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
-
19
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
18
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
19
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
21
+ following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in all copies or substantial
24
+ portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
27
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
28
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
29
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
30
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/dev.js CHANGED
@@ -1,11 +1,26 @@
1
1
  import { execaCommand } from 'execa';
2
2
  import getManifest from "./get-manifest.js";
3
- export default (() => async (browser = 'chrome') => execaCommand('vite', {
4
- env: {
5
- MANIFEST: JSON.stringify(await getManifest({
6
- browser
7
- })),
8
- TARGET: browser
9
- },
10
- stdio: 'inherit'
11
- }));
3
+ export default async function (browser = 'chrome', options) {
4
+ options = {
5
+ env: {},
6
+ log: process.env.NODE_ENV !== 'test',
7
+ stderr: 'inherit',
8
+ ...options
9
+ };
10
+ return execaCommand('vite', {
11
+ env: {
12
+ ...options.env,
13
+ MANIFEST: JSON.stringify(await getManifest({
14
+ browser,
15
+ cwd: this.cwd
16
+ })),
17
+ TARGET: browser
18
+ },
19
+ ...(options.log && {
20
+ stdout: 'inherit'
21
+ }),
22
+ cwd: this.cwd,
23
+ reject: process.env.NODE_ENV !== 'test',
24
+ stderr: options.stderr
25
+ });
26
+ }
@@ -1,13 +1,15 @@
1
+ import pathLib from 'node:path';
1
2
  import fs from 'fs-extra';
2
3
  import loadPkg from 'load-pkg';
3
4
  import { pick } from 'lodash-es';
4
- export default (async ({
5
+ export default async ({
6
+ cwd,
5
7
  browser
6
8
  }) => {
7
- const packageConfig = await loadPkg();
8
- const config = await fs.readJson('config.json').catch(() => ({}));
9
- const iconExists = await fs.exists('public/icon.png');
10
- const popupExists = await fs.exists('popup.html');
9
+ const packageConfig = await loadPkg(cwd);
10
+ const config = await fs.readJson(pathLib.join(cwd, 'config.json')).catch(() => ({}));
11
+ const iconExists = await fs.exists(pathLib.join(cwd, 'public', 'icon.png'));
12
+ const popupExists = await fs.exists(pathLib.join(cwd, 'popup.html'));
11
13
  return {
12
14
  name: config.name,
13
15
  ...pick(packageConfig, ['version', 'description']),
@@ -30,7 +32,7 @@ export default (async ({
30
32
  ...(typeof config.action === 'object' && config.action)
31
33
  }
32
34
  }),
33
- ...(((await fs.exists('content.js')) || config.css?.length > 0) && {
35
+ ...(((await fs.exists(pathLib.join(cwd, 'content.js'))) || config.css?.length > 0) && {
34
36
  content_scripts: [{
35
37
  js: ['content.js'],
36
38
  ...(config.css?.length > 0 && {
@@ -39,7 +41,7 @@ export default (async ({
39
41
  matches: config.matches || ['<all_urls>']
40
42
  }]
41
43
  }),
42
- ...((await fs.exists('background.js')) && {
44
+ ...((await fs.exists(pathLib.join(cwd, 'background.js'))) && {
43
45
  background: {
44
46
  ...(browser === 'firefox' ? {
45
47
  scripts: ['background.js']
@@ -64,4 +66,4 @@ export default (async ({
64
66
  web_accessible_resources: true
65
67
  }))
66
68
  };
67
- });
69
+ };
package/dist/index.js CHANGED
@@ -1,118 +1,114 @@
1
+ import pathLib from 'node:path';
1
2
  import depcheckParserSass from '@dword-design/depcheck-parser-sass';
2
- import { endent } from '@dword-design/functions';
3
+ import dedent from 'dedent';
3
4
  import binName from 'depcheck-bin-name';
4
5
  import packageName from 'depcheck-package-name';
5
6
  import depcheckParserVue from 'depcheck-parser-vue';
6
- import outputFiles from 'output-files';
7
+ import fs from 'fs-extra';
7
8
  import dev from "./dev.js";
8
- import lint from "./lint.js";
9
9
  import prepublishOnly from "./prepublish-only.js";
10
- export default (config => ({
11
- allowedMatches: ['assets', 'components', 'public', 'background.js', 'content.js', 'config.json', 'index.spec.js', 'options.html', 'popup.html', 'popup.js', 'popup.vue', 'options.js', 'popup.js', 'model'],
12
- commands: {
13
- dev: {
14
- arguments: '[browser]',
15
- handler: dev(config)
10
+ export default function () {
11
+ return {
12
+ allowedMatches: ['assets', 'components', 'public', 'background.js', 'content.js', 'config.json', 'index.spec.js', 'options.html', 'popup.html', 'popup.js', 'popup.vue', 'options.js', 'popup.js', 'model'],
13
+ commands: {
14
+ dev: {
15
+ arguments: '[browser]',
16
+ handler: (...args) => dev.call(this, ...args)
17
+ },
18
+ prepublishOnly: {
19
+ arguments: '[browser]',
20
+ handler: (...args) => prepublishOnly.call(this, ...args)
21
+ }
16
22
  },
17
- prepublishOnly: {
18
- arguments: '[browser]',
19
- handler: prepublishOnly(config)
20
- }
21
- },
22
- depcheckConfig: {
23
- parsers: {
24
- '**/*.scss': depcheckParserSass,
25
- '**/*.vue': depcheckParserVue
26
- }
27
- },
28
- deployAssets: [{
29
- label: 'Extension',
30
- path: 'extension.zip'
31
- }],
32
- deployEnv: {
33
- CHROME_CLIENT_ID: '${{ secrets.CHROME_CLIENT_ID }}',
34
- CHROME_CLIENT_SECRET: '${{ secrets.CHROME_CLIENT_SECRET }}',
35
- CHROME_EXTENSION_ID: '${{ secrets.CHROME_EXTENSION_ID }}',
36
- CHROME_REFRESH_TOKEN: '${{ secrets.CHROME_REFRESH_TOKEN }}',
37
- FIREFOX_EXTENSION_ID: '${{ secrets.FIREFOX_EXTENSION_ID }}',
38
- FIREFOX_JWT_ISSUER: '${{ secrets.FIREFOX_JWT_ISSUER }}',
39
- FIREFOX_JWT_SECRET: '${{ secrets.FIREFOX_JWT_SECRET }}'
40
- },
41
- deployPlugins: [[packageName`@semantic-release/exec`, {
42
- publishCmd: `yarn ${binName`publish-extension`} --chrome-zip=dist/chrome.zip --firefox-zip=dist/firefox.zip --firefox-sources-zip=dist/firefox-sources.zip`
43
- }]],
44
- editorIgnore: ['.eslintrc.json', 'dist', 'userdata', 'vite.config.js'],
45
- gitignore: ['/.eslintrc.json', '/dist', '/userdata', '/vite.config.js'],
46
- isLockFileFixCommitType: true,
47
- lint,
48
- preDeploySteps: [{
49
- run: 'yarn prepublishOnly'
50
- }, {
51
- env: {
52
- FIREFOX_EXTENSION_ID: '${{ secrets.FIREFOX_EXTENSION_ID }}'
23
+ depcheckConfig: {
24
+ parsers: {
25
+ '**/*.scss': depcheckParserSass,
26
+ '**/*.vue': depcheckParserVue
27
+ }
53
28
  },
54
- run: 'yarn prepublishOnly firefox'
55
- }, {
56
- run: 'zip -r ../chrome.zip .',
57
- 'working-directory': 'dist/chrome'
58
- }, {
59
- run: 'zip -r ../firefox.zip .',
60
- 'working-directory': 'dist/firefox'
61
- }, {
62
- run: 'git archive --output=dist/firefox-sources.zip HEAD'
63
- }],
64
- prepare: () => outputFiles({
65
- '.eslintrc.json': `${JSON.stringify({
66
- extends: packageName`@dword-design/eslint-config`
67
- }, undefined, 2)}\n`,
68
- 'vite.config.js': endent`
69
- import vue from '${packageName`@vitejs/plugin-vue`}'
70
- import P from 'path'
71
- import { defineConfig } from '${packageName`vite`}'
72
- import vueBabel from '${packageName`@dword-design/vite-plugin-vue-babel`}'
73
- import babel from '${packageName`vite-plugin-babel`}'
74
- import eslint from '${packageName`vite-plugin-eslint`}'
75
- import webExtension from '${packageName`vite-plugin-web-extension`}'
76
- import svgLoader from '${packageName`vite-svg-loader`}'
29
+ deployAssets: [{
30
+ label: 'Extension',
31
+ path: 'extension.zip'
32
+ }],
33
+ deployEnv: {
34
+ CHROME_CLIENT_ID: '${{ secrets.CHROME_CLIENT_ID }}',
35
+ CHROME_CLIENT_SECRET: '${{ secrets.CHROME_CLIENT_SECRET }}',
36
+ CHROME_EXTENSION_ID: '${{ secrets.CHROME_EXTENSION_ID }}',
37
+ CHROME_REFRESH_TOKEN: '${{ secrets.CHROME_REFRESH_TOKEN }}',
38
+ FIREFOX_EXTENSION_ID: '${{ secrets.FIREFOX_EXTENSION_ID }}',
39
+ FIREFOX_JWT_ISSUER: '${{ secrets.FIREFOX_JWT_ISSUER }}',
40
+ FIREFOX_JWT_SECRET: '${{ secrets.FIREFOX_JWT_SECRET }}'
41
+ },
42
+ deployPlugins: [[packageName`@semantic-release/exec`, {
43
+ publishCmd: `pnpm ${binName`publish-extension`} --chrome-zip=dist/chrome.zip --firefox-zip=dist/firefox.zip --firefox-sources-zip=dist/firefox-sources.zip`
44
+ }]],
45
+ editorIgnore: ['dist', 'userdata', 'vite.config.js'],
46
+ gitignore: ['/dist', '/userdata', '/vite.config.js'],
47
+ isLockFileFixCommitType: true,
48
+ preDeploySteps: [{
49
+ run: 'pnpm prepublishOnly'
50
+ }, {
51
+ env: {
52
+ FIREFOX_EXTENSION_ID: '${{ secrets.FIREFOX_EXTENSION_ID }}'
53
+ },
54
+ run: 'pnpm prepublishOnly firefox'
55
+ }, {
56
+ run: 'zip -r ../chrome.zip .',
57
+ 'working-directory': 'dist/chrome'
58
+ }, {
59
+ run: 'zip -r ../firefox.zip .',
60
+ 'working-directory': 'dist/firefox'
61
+ }, {
62
+ run: 'git archive --output=dist/firefox-sources.zip HEAD'
63
+ }],
64
+ prepare: () => Promise.all([fs.outputFile(pathLib.join(this.cwd, 'vite.config.js'), dedent`
65
+ import vue from '${packageName`@vitejs/plugin-vue`}'
66
+ import P from 'path'
67
+ import { defineConfig } from '${packageName`vite`}'
68
+ import vueBabel from '${packageName`@dword-design/vite-plugin-vue-babel`}'
69
+ import babel from '${packageName`vite-plugin-babel`}'
70
+ import eslint from '${packageName`vite-plugin-eslint`}'
71
+ import webExtension from '${packageName`vite-plugin-web-extension`}'
72
+ import svgLoader from '${packageName`vite-svg-loader`}'
77
73
 
78
- export default defineConfig({
79
- build: {
80
- outDir: P.join('dist', process.env.TARGET),
81
- },
82
- plugins: [
83
- vueBabel(),
84
- vue(),
85
- svgLoader(),
86
- eslint({ fix: true }),
87
- webExtension({
88
- browser: process.env.TARGET,
89
- manifest: () => JSON.parse(process.env.MANIFEST),
90
- scriptViteConfig: { plugins: [babel(), eslint({ fix: true })] },
91
- webExtConfig: { keepProfileChanges: true, chromiumProfile: 'userdata' },
92
- }),
93
- ],
94
- })\n
95
- `
96
- }),
97
- readmeInstallString: endent`
98
- ## Recommended setup
99
- * Node.js 20.11.1
100
- * Yarn 1.22.19
74
+ export default defineConfig({
75
+ build: {
76
+ outDir: P.join('dist', process.env.TARGET),
77
+ },
78
+ plugins: [
79
+ vueBabel(),
80
+ vue(),
81
+ svgLoader(),
82
+ eslint({ fix: true }),
83
+ webExtension({
84
+ browser: process.env.TARGET,
85
+ manifest: () => JSON.parse(process.env.MANIFEST),
86
+ scriptViteConfig: { plugins: [babel(), eslint({ fix: true })] },
87
+ webExtConfig: { keepProfileChanges: true, chromiumProfile: 'userdata' },
88
+ }),
89
+ ],
90
+ })\n
91
+ `), fs.ensureDir(pathLib.join(this.cwd, 'userdata'))]),
92
+ readmeInstallString: dedent`
93
+ ## Recommended setup
94
+ * Node.js 20.11.1
95
+ * pnpm 9.15.3
101
96
 
102
- ## Install
103
- \`\`\`bash
104
- $ yarn --frozen-lockfile
105
- \`\`\`
97
+ ## Install
98
+ \`\`\`bash
99
+ $ pnpm install --frozen-lockfile
100
+ \`\`\`
106
101
 
107
- ## Running a development server
108
- \`\`\`bash
109
- $ yarn dev [browser]
110
- \`\`\`
111
- Available browsers are \`firefox\` and \`chrome\`. Default is \`firefox\`.
102
+ ## Running a development server
103
+ \`\`\`bash
104
+ $ pnpm dev [browser]
105
+ \`\`\`
106
+ Available browsers are \`firefox\` and \`chrome\`. Default is \`firefox\`.
112
107
 
113
- ## Building the extension for upload
114
- \`\`\`bash
115
- $ yarn prepublishOnly [browser]
116
- \`\`\`
117
- `
118
- }));
108
+ ## Building the extension for upload
109
+ \`\`\`bash
110
+ $ pnpm prepublishOnly [browser]
111
+ \`\`\`
112
+ `
113
+ };
114
+ }
@@ -1,11 +1,30 @@
1
1
  import { execaCommand } from 'execa';
2
2
  import getManifest from "./get-manifest.js";
3
- export default (() => async (browser = 'chrome') => execaCommand('vite build', {
4
- env: {
5
- MANIFEST: JSON.stringify(await getManifest({
6
- browser
7
- })),
8
- TARGET: browser
9
- },
10
- stdio: 'inherit'
11
- }));
3
+ export default async function (...args) {
4
+ let options = typeof args[0] === 'string' ? args[1] : args[0];
5
+ options = {
6
+ browser: 'chrome',
7
+ env: {},
8
+ log: process.env.NODE_ENV !== 'test',
9
+ stderr: 'inherit',
10
+ ...(typeof args[0] === 'string' && {
11
+ browser: args[0]
12
+ }),
13
+ ...options
14
+ };
15
+ return execaCommand('vite build', {
16
+ env: {
17
+ ...options.env,
18
+ MANIFEST: JSON.stringify(await getManifest({
19
+ browser: options.browser,
20
+ cwd: this.cwd
21
+ })),
22
+ TARGET: options.browser
23
+ },
24
+ ...(options.log && {
25
+ stdout: 'inherit'
26
+ }),
27
+ cwd: this.cwd,
28
+ stderr: options.stderr
29
+ });
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dword-design/base-config-web-extension",
3
- "version": "3.1.6",
3
+ "version": "3.1.8",
4
4
  "repository": "dword-design/base-config-web-extension",
5
5
  "funding": "https://github.com/sponsors/dword-design",
6
6
  "license": "MIT",
@@ -19,43 +19,42 @@
19
19
  "lint": "base lint",
20
20
  "prepare": "base prepare",
21
21
  "prepublishOnly": "base prepublishOnly",
22
- "test": "base test",
23
- "test:raw": "base test:raw"
22
+ "test": "base test"
24
23
  },
25
24
  "dependencies": {
26
25
  "@dword-design/depcheck-parser-sass": "^4.0.4",
27
- "@dword-design/eslint-config": "^5.0.1",
28
- "@dword-design/functions": "^6.0.0",
29
- "@dword-design/vite-plugin-vue-babel": "^1.0.0",
26
+ "@dword-design/vite-plugin-vue-babel": "^1.0.2",
30
27
  "@semantic-release/exec": "^6.0.3",
31
- "@vitejs/plugin-vue": "^5.0.4",
32
- "depcheck-bin-name": "^1.0.0",
28
+ "@vitejs/plugin-vue": "^5.2.4",
29
+ "dedent": "^1.6.0",
30
+ "depcheck-bin-name": "^1.0.1",
33
31
  "depcheck-package-name": "^3.0.1",
34
32
  "depcheck-parser-vue": "^5.0.0",
35
- "execa": "^8.0.1",
36
- "fs-extra": "^11.1.0",
33
+ "execa": "^9.6.0",
34
+ "fs-extra": "^11.3.0",
37
35
  "load-pkg": "^4.0.0",
38
36
  "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",
37
+ "publish-browser-extension": "^2.3.1",
38
+ "vite": "^5.4.19",
39
+ "vite-plugin-babel": "^1.3.1",
43
40
  "vite-plugin-eslint": "^1.8.1",
44
- "vite-plugin-web-extension": "^4.1.1",
41
+ "vite-plugin-web-extension": "^4.4.3",
45
42
  "vite-svg-loader": "^5.1.0",
46
- "vue": "^3.4.21"
43
+ "vue": "^3.5.16"
47
44
  },
48
45
  "devDependencies": {
49
- "@dword-design/base": "^11.0.2",
50
- "@dword-design/puppeteer": "^7.0.0",
51
- "@dword-design/tester": "^2.0.4",
52
- "@dword-design/tester-plugin-tmp-dir": "^2.0.3",
46
+ "@dword-design/base": "^12.0.18",
53
47
  "@mdi/svg": "^7.4.47",
54
- "express": "^4.17.1",
55
- "globby": "^14.0.0",
56
- "webextension-polyfill": "^0.11.0",
57
- "with-local-tmp-dir": "^5.0.1"
48
+ "@playwright/test": "^1.52.0",
49
+ "express": "^4.21.2",
50
+ "get-port": "^7.1.0",
51
+ "globby": "^14.1.0",
52
+ "output-files": "^2.0.32",
53
+ "playwright": "^1.52.0",
54
+ "playwright-chromium": "^1.52.0",
55
+ "webextension-polyfill": "^0.12.0"
58
56
  },
57
+ "packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977",
59
58
  "engines": {
60
59
  "node": ">=18"
61
60
  },
package/dist/lint.js DELETED
@@ -1,10 +0,0 @@
1
- import { execaCommand } from 'execa';
2
- export default (async () => {
3
- try {
4
- await execaCommand('eslint --fix --ext .js,.json,.vue --ignore-path .gitignore .', {
5
- all: true
6
- });
7
- } catch (error) {
8
- throw new Error(error.all);
9
- }
10
- });