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

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/dist/dev.js CHANGED
@@ -1,6 +1,10 @@
1
1
  import { execaCommand } from 'execa';
2
- export default (() => browser => execaCommand('vite', {
2
+ import getManifest from "./get-manifest.js";
3
+ export default (() => async (browser = 'chrome') => execaCommand('vite', {
3
4
  env: {
5
+ MANIFEST: JSON.stringify(await getManifest({
6
+ browser
7
+ })),
4
8
  TARGET: browser
5
9
  },
6
10
  stdio: 'inherit'
@@ -4,7 +4,6 @@ import { pick } from 'lodash-es';
4
4
  export default (async ({
5
5
  browser
6
6
  }) => {
7
- var _config$css, _config$css2;
8
7
  const packageConfig = await loadPkg();
9
8
  const config = await fs.readJson('config.json').catch(() => ({}));
10
9
  const iconExists = await fs.exists('assets/icon.png');
@@ -29,10 +28,10 @@ export default (async ({
29
28
  ...(typeof config.action === 'object' && config.action)
30
29
  }
31
30
  }),
32
- ...(((await fs.exists('content.js')) || ((_config$css = config.css) === null || _config$css === void 0 ? void 0 : _config$css.length) > 0) && {
31
+ ...(((await fs.exists('content.js')) || config.css?.length > 0) && {
33
32
  content_scripts: [{
34
33
  js: ['content.js'],
35
- ...(((_config$css2 = config.css) === null || _config$css2 === void 0 ? void 0 : _config$css2.length) > 0 && {
34
+ ...(config.css?.length > 0 && {
36
35
  css: config.css
37
36
  }),
38
37
  matches: config.matches || ['<all_urls>']
@@ -48,6 +47,6 @@ export default (async ({
48
47
  })
49
48
  }
50
49
  }),
51
- ...pick(config, ['permissions', 'browser_specific_settings', 'css'])
50
+ ...pick(config, ['host_permissions', 'optional_host_permissions', 'optional_permissions', 'permissions', 'browser_specific_settings', 'css'])
52
51
  };
53
52
  });
package/dist/index.js CHANGED
@@ -1,16 +1,10 @@
1
1
  import depcheckParserSass from '@dword-design/depcheck-parser-sass';
2
- import endent from "@dword-design/functions/dist/endent.js";
2
+ import { endent } from '@dword-design/functions';
3
3
  import packageName from 'depcheck-package-name';
4
- import { createRequire } from 'module';
5
4
  import outputFiles from 'output-files';
6
- import P from 'path';
7
- import { fileURLToPath } from 'url';
8
5
  import dev from "./dev.js";
9
6
  import lint from "./lint.js";
10
7
  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
8
  export default (config => ({
15
9
  allowedMatches: ['assets', 'background.js', 'content.js', 'config.json', 'icon.png', 'index.spec.js', 'options.html', 'popup.html', 'options.js', 'popup.js', 'model'],
16
10
  commands: {
@@ -40,23 +34,37 @@ export default (config => ({
40
34
  deployPlugins: [[packageName`@semantic-release/exec`, {
41
35
  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`
42
36
  }]],
43
- editorIgnore: ['.eslintrc.json', 'dist'],
44
- gitignore: ['/.eslintrc.json', '/dist'],
37
+ editorIgnore: ['.eslintrc.json', 'dist', 'vite.config.js'],
38
+ gitignore: ['/.eslintrc.json', '/dist', '/vite.config.js'],
45
39
  isLockFileFixCommitType: true,
46
40
  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}'
41
+ prepare: () => outputFiles({
42
+ '.eslintrc.json': `${JSON.stringify({
43
+ extends: packageName`@dword-design/eslint-config`
44
+ }, undefined, 2)}\n`,
45
+ 'vite.config.js': endent`
46
+ import vue from '${packageName`@vitejs/plugin-vue`}'
47
+ import P from 'path'
48
+ import { defineConfig } from '${packageName`vite`}'
49
+ import babel from '${packageName`vite-plugin-babel`}'
50
+ import eslint from '${packageName`vite-plugin-eslint`}'
51
+ import webExtension from '${packageName`vite-plugin-web-extension`}'
55
52
 
56
- export default config
53
+ export default defineConfig({
54
+ build: {
55
+ outDir: P.join('dist', process.env.TARGET),
56
+ },
57
+ plugins: [
58
+ vue(),
59
+ webExtension({
60
+ browser: process.env.TARGET,
61
+ manifest: () => JSON.parse(process.env.MANIFEST),
62
+ scriptViteConfig: { plugins: [eslint({ fix: true }), babel()] },
63
+ }),
64
+ ],
65
+ })\n
57
66
  `
58
- });
59
- },
67
+ }),
60
68
  readmeInstallString: endent`
61
69
  ## Recommended setup
62
70
  * Node.js 20.11.1
@@ -1,6 +1,10 @@
1
1
  import { execaCommand } from 'execa';
2
- export default (() => browser => execaCommand('vite build', {
2
+ import getManifest from "./get-manifest.js";
3
+ export default (() => async (browser = 'chrome') => execaCommand('vite build', {
3
4
  env: {
5
+ MANIFEST: JSON.stringify(await getManifest({
6
+ browser
7
+ })),
4
8
  TARGET: browser
5
9
  },
6
10
  stdio: 'inherit'
package/package.json CHANGED
@@ -1,15 +1,12 @@
1
1
  {
2
2
  "name": "@dword-design/base-config-web-extension",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
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": {
10
- ".": "./dist/index.js",
11
- "./config": "./dist/config.js"
12
- },
9
+ "exports": "./dist/index.js",
13
10
  "main": "dist/index.js",
14
11
  "files": [
15
12
  "dist"
@@ -28,7 +25,7 @@
28
25
  "dependencies": {
29
26
  "@dword-design/depcheck-parser-sass": "^4.0.4",
30
27
  "@dword-design/eslint-config": "^5.0.1",
31
- "@dword-design/functions": "^5.0.27",
28
+ "@dword-design/functions": "^6.0.0",
32
29
  "@semantic-release/exec": "^6.0.3",
33
30
  "@vitejs/plugin-vue": "^5.0.4",
34
31
  "depcheck-package-name": "^3.0.1",
package/dist/config.js DELETED
@@ -1,24 +0,0 @@
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
- });