chore: Refactor folder structure
This commit is contained in:
@@ -42,7 +42,7 @@ describe('Manifest Content', () => {
|
||||
await project.build({ manifestVersion: 2 });
|
||||
|
||||
const manifest = await project.getOutputManifest(
|
||||
'.output/chromium-mv2/manifest.json',
|
||||
'.output/chrome-mv2/manifest.json',
|
||||
);
|
||||
expect(manifest[expectedType]).toEqual({
|
||||
default_icon: { '16': '/icon/16.png' },
|
||||
@@ -123,7 +123,7 @@ describe('Manifest Content', () => {
|
||||
|
||||
await project.build({ manifestVersion: 2 });
|
||||
const manifest = await project.getOutputManifest(
|
||||
'.output/chromium-mv2/manifest.json',
|
||||
'.output/chrome-mv2/manifest.json',
|
||||
);
|
||||
|
||||
expect(manifest.background).toEqual({
|
||||
|
||||
@@ -11,7 +11,7 @@ describe('Output Directory Structure', () => {
|
||||
await project.build();
|
||||
|
||||
expect(await project.serializeOutput()).toMatchInlineSnapshot(`
|
||||
".output/chromium-mv3/manifest.json
|
||||
".output/chrome-mv3/manifest.json
|
||||
----------------------------------------
|
||||
{\\"manifest_version\\":3,\\"name\\":\\"E2E Extension\\",\\"version\\":\\"0.0.0\\",\\"version_name\\":\\"0.0.0-test\\"}"
|
||||
`);
|
||||
@@ -44,31 +44,31 @@ describe('Output Directory Structure', () => {
|
||||
await project.build();
|
||||
|
||||
expect(await project.serializeOutput()).toMatchInlineSnapshot(`
|
||||
".output/chromium-mv3/assets/one-dedc7a05.css
|
||||
".output/chrome-mv3/assets/one-dedc7a05.css
|
||||
----------------------------------------
|
||||
body{color:#00f}
|
||||
|
||||
================================================================================
|
||||
.output/chromium-mv3/assets/two-74d94aed.css
|
||||
.output/chrome-mv3/assets/two-74d94aed.css
|
||||
----------------------------------------
|
||||
body{color:red}
|
||||
|
||||
================================================================================
|
||||
.output/chromium-mv3/content-scripts/one.js
|
||||
.output/chrome-mv3/content-scripts/one.js
|
||||
----------------------------------------
|
||||
(function(){\\"use strict\\";function c(n){return n}const e=\\"\\",t={matches:[\\"*://*/*\\"],main:()=>{}};(async()=>{try{await t.main()}catch(n){console.error(\`The content script crashed on startup!
|
||||
|
||||
\`,n)}})()})();
|
||||
|
||||
================================================================================
|
||||
.output/chromium-mv3/content-scripts/two.js
|
||||
.output/chrome-mv3/content-scripts/two.js
|
||||
----------------------------------------
|
||||
(function(){\\"use strict\\";function c(n){return n}const e=\\"\\",t={matches:[\\"*://*/*\\"],main:()=>{}};(async()=>{try{await t.main()}catch(n){console.error(\`The content script crashed on startup!
|
||||
|
||||
\`,n)}})()})();
|
||||
|
||||
================================================================================
|
||||
.output/chromium-mv3/manifest.json
|
||||
.output/chrome-mv3/manifest.json
|
||||
----------------------------------------
|
||||
{\\"manifest_version\\":3,\\"name\\":\\"E2E Extension\\",\\"version\\":\\"0.0.0\\",\\"version_name\\":\\"0.0.0-test\\",\\"content_scripts\\":[{\\"matches\\":[\\"*://*/*\\"],\\"css\\":[\\"assets/one-dedc7a05.css\\",\\"assets/two-74d94aed.css\\"],\\"js\\":[\\"content-scripts/one.js\\",\\"content-scripts/two.js\\"]}]}"
|
||||
`);
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('Remote Code', () => {
|
||||
|
||||
await project.build();
|
||||
|
||||
const output = await project.serializeFile('.output/chromium-mv3/popup.js');
|
||||
const output = await project.serializeFile('.output/chrome-mv3/popup.js');
|
||||
expect(output).toContain(
|
||||
// Some text that will hopefully be in future versions of this script
|
||||
'umami.disabled',
|
||||
|
||||
@@ -20,12 +20,12 @@ describe('User Config', () => {
|
||||
|
||||
const output = await project.serializeOutput();
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
".output/chromium-mv3/background.js
|
||||
".output/chrome-mv3/background.js
|
||||
----------------------------------------
|
||||
(function(){\\"use strict\\";function o(n){return typeof n==\\"function\\"?{main:n}:n}const r=o(()=>console.log(\\"Hello background\\"));try{r.main()instanceof Promise&&console.warn(\\"The background's main() function return a promise, but it must be synchonous\\")}catch(n){throw console.error(\\"The background script crashed on startup!\\"),n}})();
|
||||
|
||||
================================================================================
|
||||
.output/chromium-mv3/manifest.json
|
||||
.output/chrome-mv3/manifest.json
|
||||
----------------------------------------
|
||||
{\\"manifest_version\\":3,\\"name\\":\\"E2E Extension\\",\\"version\\":\\"0.0.0\\",\\"version_name\\":\\"0.0.0-test\\",\\"background\\":{\\"service_worker\\":\\"background.js\\"}}"
|
||||
`);
|
||||
@@ -45,12 +45,12 @@ describe('User Config', () => {
|
||||
|
||||
const output = await project.serializeOutput();
|
||||
expect(output).toMatchInlineSnapshot(`
|
||||
".output/chromium-mv3/background.js
|
||||
".output/chrome-mv3/background.js
|
||||
----------------------------------------
|
||||
(function(){\\"use strict\\";function o(n){return typeof n==\\"function\\"?{main:n}:n}const r=o(()=>console.log(\\"Hello background\\"));try{r.main()instanceof Promise&&console.warn(\\"The background's main() function return a promise, but it must be synchonous\\")}catch(n){throw console.error(\\"The background script crashed on startup!\\"),n}})();
|
||||
|
||||
================================================================================
|
||||
.output/chromium-mv3/manifest.json
|
||||
.output/chrome-mv3/manifest.json
|
||||
----------------------------------------
|
||||
{\\"manifest_version\\":3,\\"name\\":\\"E2E Extension\\",\\"version\\":\\"0.0.0\\",\\"version_name\\":\\"0.0.0-test\\",\\"background\\":{\\"service_worker\\":\\"background.js\\"}}"
|
||||
`);
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ export class TestProject {
|
||||
}
|
||||
|
||||
async getOutputManifest(
|
||||
path: string = '.output/chromium-mv3/manifest.json',
|
||||
path: string = '.output/chrome-mv3/manifest.json',
|
||||
): Promise<any> {
|
||||
return await fs.readJson(resolve(this.root, path));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getInternalConfig } from '../../utils/getInternalConfig';
|
||||
import { findEntrypoints } from '../../utils/findEntrypoints';
|
||||
import { generateTypesDir } from '../../utils/generateTypesDir';
|
||||
import { getInternalConfig } from '../../core/utils/getInternalConfig';
|
||||
import { findEntrypoints } from '../../core/build/findEntrypoints';
|
||||
import { generateTypesDir } from '../../core/build/generateTypesDir';
|
||||
import { defineCommand } from '../utils/defineCommand';
|
||||
import * as wxt from '../..';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { consola } from 'consola';
|
||||
import { printHeader } from './printHeader';
|
||||
import { formatDuration } from '../../utils/formatDuration';
|
||||
import { printHeader } from '../../core/log/printHeader';
|
||||
import { formatDuration } from '../../core/utils/formatDuration';
|
||||
|
||||
export function defineCommand<TArgs extends any[]>(
|
||||
cb: (...args: TArgs) => void | boolean | Promise<void | boolean>,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ContentScriptDefinition } from '../types';
|
||||
import { ContentScriptDefinition } from '../core/types';
|
||||
|
||||
export function defineContentScript(
|
||||
definition: ContentScriptDefinition,
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import {
|
||||
BackgroundEntrypoint,
|
||||
ContentScriptEntrypoint,
|
||||
@@ -9,10 +9,10 @@ import {
|
||||
import { resolve } from 'path';
|
||||
import { FindEntrypointsConfig, findEntrypoints } from '../findEntrypoints';
|
||||
import fs from 'fs-extra';
|
||||
import { importTsFile } from '../importTsFile';
|
||||
import { importTsFile } from '../../utils/importTsFile';
|
||||
import glob from 'fast-glob';
|
||||
|
||||
vi.mock('../importTsFile');
|
||||
vi.mock('../../utils/importTsFile');
|
||||
const importTsFileMock = vi.mocked(importTsFile);
|
||||
|
||||
vi.mock('fast-glob');
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as vite from 'vite';
|
||||
import { BuildOutput, Entrypoint, InternalConfig } from '../types';
|
||||
import { groupEntrypoints } from './groupEntrypoints';
|
||||
import { groupEntrypoints } from '../utils/groupEntrypoints';
|
||||
import * as plugins from '../vite-plugins';
|
||||
import { removeEmptyDirs } from './removeEmptyDirs';
|
||||
import { getEntrypointBundlePath } from './entrypoints';
|
||||
import { removeEmptyDirs } from '../utils/removeEmptyDirs';
|
||||
import { getEntrypointBundlePath } from '../utils/entrypoints';
|
||||
import glob from 'fast-glob';
|
||||
import fs from 'fs-extra';
|
||||
import { dirname, resolve } from 'path';
|
||||
@@ -13,9 +13,9 @@ import fs from 'fs-extra';
|
||||
import picomatch from 'picomatch';
|
||||
import { parseHTML } from 'linkedom';
|
||||
import JSON5 from 'json5';
|
||||
import { importTsFile } from './importTsFile';
|
||||
import { importTsFile } from '../utils/importTsFile';
|
||||
import glob from 'fast-glob';
|
||||
import { getEntrypointName } from './entrypoints';
|
||||
import { getEntrypointName } from '../utils/entrypoints';
|
||||
|
||||
/**
|
||||
* Return entrypoints and their configuration by looking through the
|
||||
@@ -2,9 +2,9 @@ import { createUnimport } from 'unimport';
|
||||
import { Entrypoint, InternalConfig } from '../types';
|
||||
import fs from 'fs-extra';
|
||||
import { relative, resolve } from 'path';
|
||||
import { getEntrypointBundlePath } from './entrypoints';
|
||||
import { getUnimportOptions } from './auto-imports';
|
||||
import { getGlobals } from './globals';
|
||||
import { getEntrypointBundlePath } from '../utils/entrypoints';
|
||||
import { getUnimportOptions } from '../utils/auto-imports';
|
||||
import { getGlobals } from '../utils/globals';
|
||||
|
||||
/**
|
||||
* Generate and write all the files inside the `InternalConfig.typesDir` directory.
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entrypoint } from '..';
|
||||
import { Entrypoint } from '../..';
|
||||
import { EntrypointGroup } from '../types';
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entrypoint } from '..';
|
||||
import { Entrypoint } from '../..';
|
||||
import { Manifest } from 'webextension-polyfill';
|
||||
import {
|
||||
BackgroundEntrypoint,
|
||||
+13
-13
@@ -3,24 +3,24 @@ import {
|
||||
WxtDevServer,
|
||||
InlineConfig,
|
||||
InternalConfig,
|
||||
} from './types';
|
||||
import { getInternalConfig } from './utils/getInternalConfig';
|
||||
import { findEntrypoints } from './utils/findEntrypoints';
|
||||
import { buildEntrypoints } from './utils/buildEntrypoints';
|
||||
import { generateMainfest, writeManifest } from './utils/manifest';
|
||||
import { printBuildSummary } from './utils/printBuildSummary';
|
||||
} from './core/types';
|
||||
import { getInternalConfig } from './core/utils/getInternalConfig';
|
||||
import { findEntrypoints } from './core/build/findEntrypoints';
|
||||
import { buildEntrypoints } from './core/build/buildEntrypoints';
|
||||
import { generateMainfest, writeManifest } from './core/utils/manifest';
|
||||
import { printBuildSummary } from './core/log/printBuildSummary';
|
||||
import fs from 'fs-extra';
|
||||
import { generateTypesDir } from './utils/generateTypesDir';
|
||||
import { generateTypesDir } from './core/build/generateTypesDir';
|
||||
import pc from 'picocolors';
|
||||
import * as vite from 'vite';
|
||||
import { findOpenPort } from './utils/findOpenPort';
|
||||
import { formatDuration } from './utils/formatDuration';
|
||||
import { createWebExtRunner } from './runners/createWebExtRunner';
|
||||
import { findOpenPort } from './core/utils/findOpenPort';
|
||||
import { formatDuration } from './core/utils/formatDuration';
|
||||
import { createWebExtRunner } from './core/runners/createWebExtRunner';
|
||||
|
||||
export { version } from '../package.json';
|
||||
export * from './types/external';
|
||||
export * from './utils/defineConfig';
|
||||
export * from './utils/defineRunnerConfig';
|
||||
export * from './core/types/external';
|
||||
export * from './core/utils/defineConfig';
|
||||
export * from './core/utils/defineRunnerConfig';
|
||||
|
||||
/**
|
||||
* Bundles the extension for production. Returns a promise of the build result.
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import path from 'node:path';
|
||||
|
||||
export function trimExtension(filename: string): string;
|
||||
export function trimExtension(filename: undefined): undefined;
|
||||
export function trimExtension(filename: string | undefined): string | undefined;
|
||||
export function trimExtension(
|
||||
filename: string | undefined,
|
||||
): string | undefined {
|
||||
return filename?.replace(path.extname(filename), '');
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.base.json",
|
||||
"exclude": ["dist", "demo"]
|
||||
"exclude": ["dist", "demo", "e2e/project"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user