mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
refactor: update import statements to use node built-in modules
chore: update lerna configuration formatting chore: bump version in package.json to 6.0.0 fix: modify build scripts for improved readability and consistency feat: enhance translation scripts with better error handling and progress tracking chore: improve plugin creation script for better user experience style: format svgo configuration for consistency
This commit is contained in:
1 parent
3540cd0cce
commit
fa755b5f61
11 files changed
+509
-496
No files matched your search
+78
-76
@@ -1,92 +1,94 @@
|
||||
import path from 'path';
|
||||
import servor from 'servor';
|
||||
import prompts from 'prompts';
|
||||
import { Parcel } from '@parcel/core';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { getProjects } from './utils.js';
|
||||
import openBrowser from 'servor/utils/openBrowser.js';
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { Parcel } from '@parcel/core'
|
||||
import prompts from 'prompts'
|
||||
import servor from 'servor'
|
||||
import openBrowser from 'servor/utils/openBrowser.js'
|
||||
import { getProjects } from './utils.js'
|
||||
|
||||
const projects = getProjects();
|
||||
const projects = getProjects()
|
||||
|
||||
async function develop(name) {
|
||||
const projectPath = projects[name];
|
||||
const uncompiledPath = path.resolve(`docs/uncompiled/${name}`);
|
||||
const entryFile = path.join(projectPath, 'src/index.js');
|
||||
const projectPath = projects[name]
|
||||
const uncompiledPath = path.resolve(`docs/uncompiled/${name}`)
|
||||
const entryFile = path.join(projectPath, 'src/index.js')
|
||||
|
||||
let isOpenBrowser = false;
|
||||
let isOpenBrowser = false
|
||||
|
||||
const { url } = await servor({
|
||||
root: 'docs',
|
||||
fallback: 'index.html',
|
||||
reload: true,
|
||||
port: 8082,
|
||||
});
|
||||
const { url } = await servor({
|
||||
root: 'docs',
|
||||
fallback: 'index.html',
|
||||
reload: true,
|
||||
port: 8082,
|
||||
})
|
||||
|
||||
process.chdir(projectPath);
|
||||
process.chdir(projectPath)
|
||||
|
||||
const bundler = new Parcel({
|
||||
entries: entryFile,
|
||||
defaultConfig: '@parcel/config-default',
|
||||
mode: 'development',
|
||||
targets: {
|
||||
main: {
|
||||
distDir: uncompiledPath,
|
||||
outputFormat: 'global',
|
||||
isLibrary: true,
|
||||
engines: {
|
||||
browsers: ['last 1 Chrome version'],
|
||||
},
|
||||
},
|
||||
const bundler = new Parcel({
|
||||
entries: entryFile,
|
||||
defaultConfig: '@parcel/config-default',
|
||||
mode: 'development',
|
||||
targets: {
|
||||
main: {
|
||||
distDir: uncompiledPath,
|
||||
outputFormat: 'global',
|
||||
isLibrary: true,
|
||||
engines: {
|
||||
browsers: ['last 1 Chrome version'],
|
||||
},
|
||||
env: {
|
||||
NODE_ENV: 'development',
|
||||
},
|
||||
additionalReporters: [
|
||||
{
|
||||
packageName: '@parcel/reporter-cli',
|
||||
resolveFrom: fileURLToPath(import.meta.url),
|
||||
},
|
||||
],
|
||||
});
|
||||
},
|
||||
},
|
||||
env: {
|
||||
NODE_ENV: 'development',
|
||||
},
|
||||
additionalReporters: [
|
||||
{
|
||||
packageName: '@parcel/reporter-cli',
|
||||
resolveFrom: fileURLToPath(import.meta.url),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
bundler.watch((error, event) => {
|
||||
if (error) {
|
||||
console.error(`[${name}] ❌ Build error:`, error);
|
||||
return;
|
||||
}
|
||||
bundler.watch((error, event) => {
|
||||
if (error) {
|
||||
console.error(`[${name}] ❌ Build error:`, error)
|
||||
return
|
||||
}
|
||||
|
||||
if (event.type === 'buildSuccess') {
|
||||
const bundles = event.bundleGraph.getBundles();
|
||||
console.log(`[${name}] ✅ Built ${bundles.length} bundles in ${event.buildTime}ms`);
|
||||
if (!isOpenBrowser) {
|
||||
isOpenBrowser = true;
|
||||
openBrowser(url);
|
||||
}
|
||||
}
|
||||
if (event.type === 'buildSuccess') {
|
||||
const bundles = event.bundleGraph.getBundles()
|
||||
console.log(`[${name}] ✅ Built ${bundles.length} bundles in ${event.buildTime}ms`)
|
||||
if (!isOpenBrowser) {
|
||||
isOpenBrowser = true
|
||||
openBrowser(url)
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type === 'buildFailure') {
|
||||
console.error(`[${name}] ❌ Build failure:`, event.diagnostics);
|
||||
}
|
||||
});
|
||||
if (event.type === 'buildFailure') {
|
||||
console.error(`[${name}] ❌ Build failure:`, event.diagnostics)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const response = await prompts({
|
||||
type: 'select',
|
||||
name: 'value',
|
||||
message: 'Which project do you want to develop?',
|
||||
choices: Object.keys(projects).map((name) => ({
|
||||
title: name,
|
||||
value: name,
|
||||
})),
|
||||
initial: 0,
|
||||
});
|
||||
try {
|
||||
const response = await prompts({
|
||||
type: 'select',
|
||||
name: 'value',
|
||||
message: 'Which project do you want to develop?',
|
||||
choices: Object.keys(projects).map(name => ({
|
||||
title: name,
|
||||
value: name,
|
||||
})),
|
||||
initial: 0,
|
||||
})
|
||||
|
||||
if (response.value) {
|
||||
await develop(response.value);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`❌ Prompt error: ${error.message}`);
|
||||
if (response.value) {
|
||||
await develop(response.value)
|
||||
}
|
||||
})();
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`❌ Prompt error: ${error.message}`)
|
||||
}
|
||||
})()
|
||||
Reference in new issue
Block a user