diff --git a/examples/data.ts b/examples/data.ts index 66401f35..3c93a28a 100644 --- a/examples/data.ts +++ b/examples/data.ts @@ -316,11 +316,7 @@ const ALL_TEMPLATES_BUT_DEFAULT = ALL_TEMPLATES.filter( (template) => template.name !== 'init' ) -const SUPPORTED_BROWSERS: string[] = [ - 'chrome', - 'edge', - 'firefox' -] +const SUPPORTED_BROWSERS: string[] = ['chrome', 'edge', 'firefox'] export { SUPPORTED_BROWSERS, diff --git a/programs/cli/__spec__/cli.spec.ts b/programs/cli/__spec__/cli.spec.ts index 81b2e7b9..68293662 100644 --- a/programs/cli/__spec__/cli.spec.ts +++ b/programs/cli/__spec__/cli.spec.ts @@ -6,15 +6,15 @@ // ╚═════╝╚══════╝╚═╝ import path from 'path' -import {exec} from 'child_process' +import {execFile} from 'child_process' import {promisify} from 'util' -const execAsync = promisify(exec) +const execFileAsync = promisify(execFile) export async function extensionProgram(command: string = '') { const cliDirectory = path.resolve(__dirname, '..', 'dist', 'cli.js') - const cliCommand = `node ${cliDirectory} ${command}` - return await execAsync(cliCommand) + const args = command ? command.split(' ') : [] + return await execFileAsync('node', [cliDirectory, ...args]) } describe('CLI Commands', () => { diff --git a/programs/cli/spec/helpers.ts b/programs/cli/spec/helpers.ts deleted file mode 100644 index 48171247..00000000 --- a/programs/cli/spec/helpers.ts +++ /dev/null @@ -1,84 +0,0 @@ -// ██████╗██╗ ██╗ -// ██╔════╝██║ ██║ -// ██║ ██║ ██║ -// ██║ ██║ ██║ -// ╚██████╗███████╗██║ -// ╚═════╝╚══════╝╚═╝ - -import path from 'path' -import fs from 'fs' -import {exec} from 'child_process' -import {promisify} from 'util' -import {ALL_TEMPLATES} from '../../../examples/data' - -const execAsync = promisify(exec) - -export async function extensionProgram(command: string = '') { - const cliCommand = `npx -y extension@latest ${command}` - return await execAsync(cliCommand) -} - -export async function localExtensionProgram(command: string = '') { - const cliCommand = `node ${path.join( - __dirname, - '..', - '..', - 'dist', - 'cli.js' - )} ${command}` - return await execAsync(cliCommand) -} - -export function fileExists(template: string, filePath?: string): boolean { - const templatePath = path.join(__dirname, '..', '..', 'dist', template) - return fs.existsSync(path.join(templatePath, filePath || '')) -} - -export function distFileExists( - template: string, - browser: string, - filePath?: string -): boolean { - const templatePath = path.join(__dirname, template, 'dist', browser) - - return fs.existsSync(path.join(templatePath, filePath || '')) -} - -export async function removeDir(dirPath: string) { - if (fs.existsSync(dirPath)) { - await fs.promises.rm(dirPath, {recursive: true}) - } -} - -export async function removeAllTemplateFolders() { - await Promise.all( - ALL_TEMPLATES.map(async (template) => { - const templatePath = path.join( - __dirname, - '..', - '..', - 'dist', - template.name - ) - - await removeDir(templatePath) - return true - }) - ) -} - -export async function removeAllTemplateDistFolders() { - await Promise.all( - ALL_TEMPLATES.map(async (template) => { - const templatePath = path.join( - __dirname, - 'fixtures', - template.name, - 'dist' - ) - - await removeDir(templatePath) - return true - }) - ) -} diff --git a/programs/develop/package.json b/programs/develop/package.json index 73077a7e..c15c11e5 100644 --- a/programs/develop/package.json +++ b/programs/develop/package.json @@ -53,6 +53,7 @@ "go-git-it": "^2.0.1", "ignore": "^5.3.1", "loader-utils": "^3.3.1", + "micromatch": "^4.0.7", "mini-css-extract-plugin": "^2.8.1", "parse5": "^7.1.2", "parse5-utils": "^2.0.0", @@ -63,6 +64,7 @@ "style-loader": "^3.3.4", "swc-loader": "^0.2.6", "tiny-glob": "^0.2.9", + "vue-template-compiler": "^2.7.16", "webextension-polyfill": "^0.12.0", "webpack": "~5.92.0", "webpack-dev-server": "^5.0.2",