Skip to content

Commit

Permalink
⚡ Make a versions.js file that checks and returns used nw.js and pixi…
Browse files Browse the repository at this point in the history
….js versions. versions.js should now be used as a source of truth about used nw.js and pixi versions.

Closes #305
  • Loading branch information
CosmoMyzrailGorynych committed Jan 7, 2022
1 parent 1e7b967 commit ed2874a
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ app/export

# editor-specific
.vscode/settings.json
.vscode/launch.json

# docs
docs/db.json
Expand Down
5 changes: 1 addition & 4 deletions .vscode/launch.json → .vscode/launch-template.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "nwjs",
"request": "launch",
"name": "Launch ct.js",
"nwjsVersion": "0.59.0",
"nwjsVersion": "(this should be filled by devSetup.gulpfile.js)",
"runtimeArgs": [
"--nwapp=${workspaceFolder}/app"
],
Expand Down
9 changes: 0 additions & 9 deletions app/data/ct.release/pixi-legacy.min.js

This file was deleted.

1 change: 0 additions & 1 deletion app/data/ct.release/pixi-legacy.min.js.map

This file was deleted.

9 changes: 0 additions & 9 deletions app/data/ct.release/pixi.min.js

This file was deleted.

1 change: 0 additions & 1 deletion app/data/ct.release/pixi.min.js.map

This file was deleted.

12 changes: 1 addition & 11 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@
"monaco-themes": "^0.3.3",
"nanoid": "^3.1.30",
"opentype.js": "^1.3.3",
"pixi-particles": "^4.2.1",
"pixi-particles": "4.3.1",
"pixi.js-legacy": "5.3.11",
"pixi.js": "5.3.11",
"png2icons": "^2.0.1",
"serve-handler": "^6.1.3",
"terser": "^5.3.5",
Expand Down
18 changes: 16 additions & 2 deletions devSetup.gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
'use strict';

const versions = require('./versions');

/* eslint no-console: 0 */
const spawnise = require('./node_requires/spawnise'),
gulp = require('gulp'),
minimist = require('minimist');

const fs = require('fs-extra');

const argv = minimist(process.argv.slice(2));

spawnise.logs = argv.logs || false; // gulp --logs
Expand All @@ -31,7 +35,6 @@ const npmInstall = path => done => {

const bakeDocs = async () => {
const npm = (/^win/).test(process.platform) ? 'npm.cmd' : 'npm';
const fs = require('fs-extra');
await fs.remove('./app/data/docs/');
await spawnise.spawn(npm, ['run', 'build'], {
cwd: './docs'
Expand All @@ -42,6 +45,14 @@ const bakeDocs = async () => {
const updateGitSubmodules = () =>
spawnise.spawn('git', ['submodule', 'update', '--init', '--recursive']);

const makeVSCodeLaunchJson = () => {
const template = require('./.vscode/launch-template.json');
template.configurations.find(c => c.type === 'nwjs').nwjsVersion = versions.nwjs;
return fs.outputJson('./.vscode/launch.json', template, {
spaces: 4
});
};

const defaultTask = gulp.series([
updateGitSubmodules,
gulp.parallel([
Expand All @@ -50,7 +61,10 @@ const defaultTask = gulp.series([
npmInstall('./docs')
]),
cleanup,
bakeDocs
gulp.parallel([
bakeDocs,
makeVSCodeLaunchJson
])
]);

gulp.task('default', defaultTask);
4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const versions = require('./versions');

/* eslint no-console: 0 */
const path = require('path'),
gulp = require('gulp'),
Expand Down Expand Up @@ -45,7 +47,7 @@ const path = require('path'),
*/
const nwSource = void 0;
const nwManifest = void 0;
const nwVersion = '0.59.0',
const nwVersion = versions.nwjs,
platforms = ['osx64', 'win32', 'win64', 'linux32', 'linux64'],
nwFiles = ['./app/**', '!./app/export/**', '!./app/projects/**', '!./app/exportDesktop/**', '!./app/cache/**', '!./app/.vscode/**', '!./app/JamGames/**'];

Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions src/node_requires/exporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,15 @@ const exportCtProject = async (project, projdir, production) => {

/* Pixi.js */
if (settings.rendering.usePixiLegacy) {
await fs.copyFile(basePath + 'ct.release/pixi-legacy.min.js', path.join(writeDir, '/pixi.min.js'));
await fs.copyFile(basePath + 'ct.release/pixi-legacy.min.js.map', path.join(writeDir, '/pixi-legacy.min.js.map'));
await fs.copyFile('./node_modules/pixi.js-legacy/dist/pixi-legacy.min.js', path.join(writeDir, '/pixi.min.js'));
await fs.copyFile('./node_modules/pixi.js-legacy/dist/pixi-legacy.min.js.map', path.join(writeDir, '/pixi-legacy.min.js.map'));
} else {
await fs.copyFile(basePath + 'ct.release/pixi.min.js', path.join(writeDir, '/pixi.min.js'));
await fs.copyFile(basePath + 'ct.release/pixi.min.js.map', path.join(writeDir, '/pixi.min.js.map'));
await fs.copyFile('./node_modules/pixi.js/dist/pixi.min.js', path.join(writeDir, '/pixi.min.js'));
await fs.copyFile('./node_modules/pixi.js/dist/pixi.min.js.map', path.join(writeDir, '/pixi.min.js.map'));
}
if (project.emitterTandems && project.emitterTandems.length) {
await fs.copyFile(basePath + 'ct.release/pixi-particles.min.js', path.join(writeDir, '/pixi-particles.min.js'));
await fs.copyFile('./node_modules/pixi-particles/dist/pixi-particles.min.js', path.join(writeDir, '/pixi-particles.min.js'));
await fs.copyFile('./node_modules/pixi-particles/dist/pixi-particles.min.js.map', path.join(writeDir, '/pixi-particles.min.js.map'));
}

const startroom = getStartingRoom(project);
Expand Down
37 changes: 37 additions & 0 deletions versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This file returns versions for nw.js and pixi.js, as well as checks
* that pixi.js versions used for game packaging are the same.
*/

const appManifest = require('./app/package.json');

const unfixedRegex = /^[~^]|^[\d.]+-[\d.]+$/;

const versionMessage = 'versions.js has found an error in ct.js configuration!';
const makeTab = () => console.error(`╭─${'─'.repeat(versionMessage.length)}─╮
${versionMessage}
╰─${'─'.repeat(versionMessage.length)}─╯`);

const packagesToCheck = {
pixi: 'pixi.js',
pixiLegacy: 'pixi.js-legacy',
pixiParticles: 'pixi-particles'
};
const packageVersions = {};
for (const packageKey in packagesToCheck) {
packageVersions[packageKey] = appManifest.dependencies[packagesToCheck[packageKey]];
if (!packageVersions[packageKey] || unfixedRegex.test(packageVersions[packageKey])) {
makeTab();
throw new Error(`${packageKey} package used in the app folder is not set to a fixed version. This must be fixed. Current value is "${packageVersions[packageKey]}".`);
}
}

if (packageVersions.pixi !== packageVersions.pixiLegacy) {
makeTab();
throw new Error(`pixi.js-legacy and pixi.js packages in the app folder are not equal. This must be fixed. Current values are "${packageVersions.pixiLegacy}" for pixi.js-legacy and "${packageVersions.pixi}" for pixi.js.`);
}

module.exports = {
nwjs: '0.59.0',
...packageVersions
};

0 comments on commit ed2874a

Please sign in to comment.