mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2025-07-11 20:34:12 -04:00
fix: lint errors
This commit is contained in:
parent
8989601dd6
commit
725e1d0007
6 changed files with 57 additions and 55 deletions
|
@ -8,8 +8,7 @@ const rendererConfig = require('../webpack.renderer.js');
|
||||||
|
|
||||||
const PORT = process.env.PORT || 8601;
|
const PORT = process.env.PORT || 8601;
|
||||||
|
|
||||||
const buildRenderer = () => {
|
const buildRenderer = () => new Promise((resolve, reject) => {
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
console.log(chalk.cyan('Building renderer process...'));
|
console.log(chalk.cyan('Building renderer process...'));
|
||||||
|
|
||||||
const compiler = webpack(rendererConfig);
|
const compiler = webpack(rendererConfig);
|
||||||
|
@ -23,7 +22,6 @@ const buildRenderer = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
const startRenderer = async () => {
|
const startRenderer = async () => {
|
||||||
console.log(chalk.cyan('Starting Webpack Dev Server...'));
|
console.log(chalk.cyan('Starting Webpack Dev Server...'));
|
||||||
|
@ -47,7 +45,7 @@ const startRenderer = async () => {
|
||||||
console.error(chalk.red('Failed to start Webpack Dev Server:', err));
|
console.error(chalk.red('Failed to start Webpack Dev Server:', err));
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const startElectron = async () => {
|
const startElectron = async () => {
|
||||||
console.log(chalk.cyan('Starting Electron...'));
|
console.log(chalk.cyan('Starting Electron...'));
|
||||||
|
@ -60,7 +58,7 @@ const startElectron = async () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const start = async () => {
|
const start = () => {
|
||||||
console.log(chalk.green('Building main process...'));
|
console.log(chalk.green('Building main process...'));
|
||||||
|
|
||||||
const mainProcess = spawn('npm', ['run', 'compile:main'], {
|
const mainProcess = spawn('npm', ['run', 'compile:main'], {
|
||||||
|
@ -68,7 +66,7 @@ const start = async () => {
|
||||||
shell: true
|
shell: true
|
||||||
});
|
});
|
||||||
|
|
||||||
mainProcess.on('exit', async (code) => {
|
mainProcess.on('exit', async code => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
console.log(chalk.green('Main process built successfully!'));
|
console.log(chalk.green('Main process built successfully!'));
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ const displayPermissionDeniedWarning = (browserWindow, permissionType) => {
|
||||||
const makeFullUrl = (url, search = null) => {
|
const makeFullUrl = (url, search = null) => {
|
||||||
const baseUrl = (isDevelopment ?
|
const baseUrl = (isDevelopment ?
|
||||||
`http://localhost:${PORT}/` :
|
`http://localhost:${PORT}/` :
|
||||||
`file://${path.join(__dirname, "../renderer")}/`
|
`file://${path.join(__dirname, '../renderer')}/`
|
||||||
);
|
);
|
||||||
const fullUrl = new URL(url, baseUrl);
|
const fullUrl = new URL(url, baseUrl);
|
||||||
if (search) {
|
if (search) {
|
||||||
|
@ -469,7 +469,7 @@ const initialProjectDataPromise = (async () => {
|
||||||
const projectData = await promisify(fs.readFile)(projectPath, null);
|
const projectData = await promisify(fs.readFile)(projectPath, null);
|
||||||
return projectData;
|
return projectData;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error(`Error loading project data: ${e}`)
|
log.error(`Error loading project data: ${e}`);
|
||||||
dialog.showMessageBox(_windows.main, {
|
dialog.showMessageBox(_windows.main, {
|
||||||
type: 'error',
|
type: 'error',
|
||||||
title: 'Failed to load project',
|
title: 'Failed to load project',
|
||||||
|
|
|
@ -34,4 +34,4 @@ routeModulePromise.then(routeModule => {
|
||||||
const appTarget = document.getElementById('app');
|
const appTarget = document.getElementById('app');
|
||||||
const routeElement = routeModule.default;
|
const routeElement = routeModule.default;
|
||||||
ReactDOM.render(routeElement, appTarget);
|
ReactDOM.render(routeElement, appTarget);
|
||||||
}).catch(error => log.error("Error rendering app: ", error));
|
}).catch(error => log.error('Error rendering app: ', error));
|
||||||
|
|
|
@ -4,7 +4,7 @@ const makeConfig = require('./webpack.makeConfig.js');
|
||||||
|
|
||||||
module.exports = makeConfig(
|
module.exports = makeConfig(
|
||||||
{
|
{
|
||||||
target: "electron-main",
|
target: 'electron-main',
|
||||||
entry: {
|
entry: {
|
||||||
main: './src/main/index.js'
|
main: './src/main/index.js'
|
||||||
},
|
},
|
||||||
|
@ -22,7 +22,7 @@ module.exports = makeConfig(
|
||||||
chunkFilename: '[name].bundle.js',
|
chunkFilename: '[name].bundle.js',
|
||||||
assetModuleFilename: 'static/assets/[name].[hash][ext]',
|
assetModuleFilename: 'static/assets/[name].[hash][ext]',
|
||||||
libraryTarget: 'commonjs2',
|
libraryTarget: 'commonjs2',
|
||||||
path: path.resolve(__dirname, "dist/main")
|
path: path.resolve(__dirname, 'dist/main')
|
||||||
},
|
},
|
||||||
module: {rules: []},
|
module: {rules: []},
|
||||||
node: {__dirname: false, __filename: false}
|
node: {__dirname: false, __filename: false}
|
||||||
|
|
|
@ -94,7 +94,7 @@ const makeConfig = function (defaultConfig, options) {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -120,15 +120,17 @@ const makeConfig = function (defaultConfig, options) {
|
||||||
filename: '[file].map'
|
filename: '[file].map'
|
||||||
}),
|
}),
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
__static: isProduction ? 'process.resourcesPath + "/static"' : JSON.stringify(path.resolve(process.cwd(), 'static')),
|
__static: isProduction ?
|
||||||
}),
|
'process.resourcesPath + "/static"' :
|
||||||
|
JSON.stringify(path.resolve(process.cwd(), 'static'))
|
||||||
|
})
|
||||||
].concat(options.plugins || []),
|
].concat(options.plugins || []),
|
||||||
resolve: {
|
resolve: {
|
||||||
cacheWithContext: false,
|
cacheWithContext: false,
|
||||||
symlinks: false,
|
symlinks: false,
|
||||||
// attempt to resolve file extensions in this order
|
// attempt to resolve file extensions in this order
|
||||||
// (allows leaving off the extension when importing)
|
// (allows leaving off the extension when importing)
|
||||||
extensions: [".js", ".jsx", ".json", ".node", ".css"],
|
extensions: ['.js', '.jsx', '.json', '.node', '.css']
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fsExtra = require("fs-extra");
|
const fsExtra = require('fs-extra');
|
||||||
|
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
|
|
||||||
|
@ -9,21 +9,23 @@ const makeConfig = require('./webpack.makeConfig.js');
|
||||||
|
|
||||||
const getModulePath = moduleName => path.dirname(require.resolve(`${moduleName}`));
|
const getModulePath = moduleName => path.dirname(require.resolve(`${moduleName}`));
|
||||||
|
|
||||||
function generateIndexFile(template) {
|
const generateIndexFile = template => {
|
||||||
let html = template;
|
let html = template;
|
||||||
|
|
||||||
html = html.replace("</head>", '<script>require("source-map-support/source-map-support.js").install()</script></head>')
|
html = html.replace(
|
||||||
|
'</head>', '<script>require("source-map-support/source-map-support.js").install()</script></head>'
|
||||||
|
);
|
||||||
|
|
||||||
const filePath = path.join("dist", ".renderer-index-template.html");
|
const filePath = path.join('dist', '.renderer-index-template.html');
|
||||||
fsExtra.outputFileSync(filePath, html);
|
fsExtra.outputFileSync(filePath, html);
|
||||||
return `!!html-loader?minimize=false&attributes=false!${filePath}`
|
return `!!html-loader?minimize=false&attributes=false!${filePath}`;
|
||||||
}
|
};
|
||||||
|
|
||||||
let template = fsExtra.readFileSync("src/renderer/index.html", {encoding: "utf8"});
|
const template = fsExtra.readFileSync('src/renderer/index.html', {encoding: 'utf8'});
|
||||||
|
|
||||||
module.exports = makeConfig(
|
module.exports = makeConfig(
|
||||||
{
|
{
|
||||||
target: "electron-renderer",
|
target: 'electron-renderer',
|
||||||
entry: {
|
entry: {
|
||||||
renderer: './src/renderer/index.js'
|
renderer: './src/renderer/index.js'
|
||||||
},
|
},
|
||||||
|
@ -31,27 +33,27 @@ module.exports = makeConfig(
|
||||||
externals: [
|
externals: [
|
||||||
'source-map-support',
|
'source-map-support',
|
||||||
'electron',
|
'electron',
|
||||||
'webpack',
|
'webpack'
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
assetModuleFilename: 'static/assets/[name].[hash][ext]',
|
assetModuleFilename: 'static/assets/[name].[hash][ext]',
|
||||||
chunkFilename: '[name].bundle.js',
|
chunkFilename: '[name].bundle.js',
|
||||||
libraryTarget: 'commonjs2',
|
libraryTarget: 'commonjs2',
|
||||||
path: path.resolve(__dirname, "dist/renderer"),
|
path: path.resolve(__dirname, 'dist/renderer')
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.node$/,
|
test: /\.node$/,
|
||||||
use: "node-loader"
|
use: 'node-loader'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\.(html)$/,
|
test: /\.(html)$/,
|
||||||
use: { "loader": "html-loader" }
|
use: {loader: 'html-loader'}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'renderer',
|
name: 'renderer',
|
||||||
|
@ -65,9 +67,9 @@ module.exports = makeConfig(
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
filename: "index.html",
|
filename: 'index.html',
|
||||||
template: generateIndexFile(template),
|
template: generateIndexFile(template),
|
||||||
minify: false,
|
minify: false
|
||||||
}),
|
}),
|
||||||
new CopyWebpackPlugin({
|
new CopyWebpackPlugin({
|
||||||
patterns: [
|
patterns: [
|
||||||
|
@ -90,7 +92,7 @@ module.exports = makeConfig(
|
||||||
noErrorOnMissing: true
|
noErrorOnMissing: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}),
|
})
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue