fix(build): get piskel to build (#12)

* chore(deps): update phantomjs to v2.1.16

* chore(deps): replace `dateformat` with `date-fns`

* chore(deps): update deps to latest

* chore

* fix(build): extract nw config outside grunt

* chore(build): update build config

* chore(build): update nw config

* chore(deps): remove unused deps

* chore(deps): remove `grunt-jscs`

* chore(test): debug nw

* chore(build): copy nw package.json from src to dest
This commit is contained in:
Ayushman Chhabra 2022-09-27 14:38:39 -04:00 committed by GitHub
parent 2f8b3fc7b6
commit 1ad296ad25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 14386 additions and 295 deletions

View File

@ -1,25 +0,0 @@
engines:
csslint:
enabled: true
duplication:
enabled: true
config:
languages:
- javascript
eslint:
enabled: true
checks:
wrap-iife:
enabled: false
fixme:
enabled: true
ratings:
paths:
- "**.css"
- "**.js"
exclude_paths:
- .github/
- bin/
- misc/
- src/js/lib/
- test/

View File

View File

37
.gitignore vendored
View File

@ -1,40 +1,13 @@
# mac artifacts
*.DS_Store
# system
.DS_Store
# nodejs local installs
# runtime
node_modules
npm-debug.log
# node webkit cache
# application
cache
# sublime text stuff (the -project should actually be shared, but then we'd have to share the same disk location)
*.sublime-project
*.sublime-workspace
# netbeans project folder
nbproject
# vscode workspace folder
.vscode
# git stackdumps
*.stackdump
# diffs
diff.txt
# build destination
dest
build/closure/closure_compiled_binary.js
# spriting artifacts
src/css/icons.css
src/img/icons.png
src/img/icons@2x.png
src/css/icons.css
# plato report directory
report
# marked as private
*.private.*

View File

@ -1,3 +0,0 @@
node_modules/
test/

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
18.9.0

View File

@ -1,10 +0,0 @@
language: node_js
node_js:
- "7.4.0"
before_install:
- npm update -g npm
- npm install -g grunt-cli
before_script:
- phantomjs --version
- casperjs --version
sudo: false

View File

@ -10,8 +10,8 @@ module.exports = function(grunt) {
};
// create a version based on the build timestamp
var dateFormat = require('dateformat');
var version = '-' + dateFormat(new Date(), "yyyy-mm-dd-hh-MM");
var { format } = require('date-fns');
var version = `-${format(new Date(), "yyyy-MM-dd-HH-mm")}`;
var releaseVersion = require('./package.json').version;
/**
@ -219,6 +219,7 @@ module.exports = function(grunt) {
{src: ['dest/tmp/index.html'], dest: 'dest/prod/index.html'},
{src: ['src/logo.png'], dest: 'dest/prod/logo.png'},
{src: ['src/js/lib/gif/gif.ie.worker.js'], dest: 'dest/prod/js/lib/gif/gif.ie.worker.js'},
{src: ['src/package.json'], dest: 'dest/prod/package.json'},
{expand: true, src: ['img/**'], cwd: 'src/', dest: 'dest/prod/', filter: 'isFile'},
{expand: true, src: ['css/fonts/**'], cwd: 'src/', dest: 'dest/prod/', filter: 'isFile'}
]
@ -264,45 +265,6 @@ module.exports = function(grunt) {
}
}
},
/**
* DESKTOP BUILDS
*/
nwjs: {
windows : {
options: {
downloadUrl: 'https://dl.nwjs.io/',
version : "0.19.4",
build_dir: './dest/desktop/', // destination folder of releases.
win: true,
linux32: true,
linux64: true,
flavor: "normal",
},
src: ['./dest/prod/**/*', "./package.json", "!./dest/desktop/"]
},
macos : {
options: {
downloadUrl: 'https://dl.nwjs.io/',
osx64: true,
version : "0.19.4",
build_dir: './dest/desktop/',
flavor: "normal",
},
src: ['./dest/prod/**/*', "./package.json", "!./dest/desktop/"]
},
macos_old : {
options: {
downloadUrl: 'https://dl.nwjs.io/',
osx64: true,
version : "0.12.3",
build_dir: './dest/desktop/old',
flavor: "normal",
},
src: ['./dest/prod/**/*', "./package.json", "!./dest/desktop/"]
}
}
});
// TEST TASKS
@ -328,9 +290,6 @@ module.exports = function(grunt) {
grunt.registerTask('merge-statics', ['concat:js', 'concat:css', 'uglify']);
grunt.registerTask('build', ['clean:prod', 'sprite', 'merge-statics', 'build-index.html', 'replace:mainPartial', 'replace:css', 'copy:prod']);
grunt.registerTask('build-dev', ['clean:dev', 'sprite', 'build-index.html', 'copy:dev']);
grunt.registerTask('desktop', ['clean:desktop', 'default', 'nwjs:windows']);
grunt.registerTask('desktop-mac', ['clean:desktop', 'default', 'nwjs:macos']);
grunt.registerTask('desktop-mac-old', ['clean:desktop', 'default', 'replace:desktop', 'nwjs:macos_old']);
// SERVER TASKS
// Start webserver and watch for changes
@ -338,12 +297,6 @@ module.exports = function(grunt) {
// Start webserver on src folder, in debug mode
grunt.registerTask('play', ['build-dev', 'connect:dev', 'watch:dev']);
// ALIASES, kept for backward compatibility
grunt.registerTask('serve-debug', ['play']);
grunt.registerTask('serve-dev', ['play']);
grunt.registerTask('test-travis', ['test']);
grunt.registerTask('test-local', ['test']);
// Default task
grunt.registerTask('default', ['lint', 'build']);
};

View File

@ -1,32 +0,0 @@
# Release instructions
- retrieve source code and dependencies
- clone piskel `git clone https://github.com/piskelapp/piskel`
- clone piskel website `git clone https://github.com/piskelapp/piskel-website`
- download the appengine SDK for python at [this url](https://cloud.google.com/appengine/docs/standard/python/download). It seems recent versions don't work for me on Windows. [GoogleAppEngine-1.9.67.msi](https://storage.cloud.google.com/appengine-sdks/featured/GoogleAppEngine-1.9.67.msi?_ga=2.6838962.-1257793585.1543157659) looks ok...
- prepare the release
- in `piskel-website` clone, checkout the `master` branch, not the `release`. The release branch is similar to the master branch, except it doesn't ignore the statics files coming from the `piskel` project. The idea is that we can easily checkout the release branch to do a new release, without having to rebuild piskel, in case nothing changed in piskel itself. We will switch to the release branch when we perform the final release.
- in `piskel` clone, create a new branch for the release `git checkout -b vX.Y`
- build and copy piskel to piskel-website (assumes the clones are in the same folder) `grunt && node bin/copy-to-piskel-website.js`
- local test
- start piskel-website in the Google app engine launcher, test manually the update
- if any issue is detected create a commit to fix it (on the `vX.Y` branch) and push it.
- beta test
- check the version in app.yaml is set to 'beta'. For historical reasons, alpha is the "production" version, while beta is the ... beta version. Don't ask.
- in the google app engine launcher, deploy this version.
- go to https://beta-dot-piskel-app.appspot.com and test (while this is not production frontend, it shares the same database, so be careful with what you create and delete)
- if any issue is detected create a commit to fix it (on `master`) and push it.
- check caches...
- If any icon was modified or any script of piskel-website was modified, there's no nice way to clean the cache on each release... so we just put a time stamp in the requests. eg `background-image: url(../img/icons@2x.png?20181125);` or `<script type="text/javascript" src="/static/js/piskel-animated-preview.js?20181124"></script>`. Erk.
- finalize the release
- in `piskel` update version in package.json. Remove the "-SNAPSHOT" at the end and commit the change, with a commit message such as `release: bump version to vX.Y`.
- in `piskel-website` checkout the `release` branch. Rebase it on master (that's pretty bad, we should probably cherry pick all the changes between the two branches...)
- once again build and copy piskel to piskel-website
- in `piskel-website` run `git status` to check that there are a bunch of changes to commit. (test locally again if you are paranoid)
- in `piskel-website` commit the current changes with a commit message such as `update statics for release vX.Y`
- Check that the version in app.yaml is now set to alpha. Deploy. Pray.
- post release
- in piskel-website push the release branch to github
- in piskel add a last commit to update the version in package.json to update the version to `vX+1.0-SNAPSHOT`
- create a tag on github

View File

@ -1,84 +0,0 @@
const rmdir = require('rmdir');
const path = require('path');
const fs = require('fs');
const fse = require('fs-extra');
const PISKEL_PATH = path.resolve(__dirname, '..');
const PISKELAPP_PATH = path.resolve(__dirname, '../../piskel-website');
var pjson = require('../package.json');
// Callbacks sorted by call sequence.
function onCopy(err) {
if (err) {
console.error('Failed to copy static files...');
return console.error(err);
}
console.log('Copied static files to piskel-website...');
let previousPartialPath = path.resolve(PISKELAPP_PATH, 'templates/editor/main-partial.html');
fs.access(previousPartialPath, fs.constants.F_OK, function (err) {
if (err) {
// File does not exit, call next step directly.
console.error('Previous main partial doesn\'t exist yet.');
onDeletePreviousPartial();
} else {
// File exists, try to delete it before moving on.
fs.unlink(previousPartialPath, onDeletePreviousPartial);
}
})
}
function onDeletePreviousPartial(err) {
if (err) {
console.error('Failed to delete previous main partial...');
return console.error(err);
}
console.log('Previous main partial deleted...');
fse.copy(
path.resolve(PISKELAPP_PATH, "static/editor/piskelapp-partials/main-partial.html"),
path.resolve(PISKELAPP_PATH, "templates/editor/main-partial.html"),
onCopyNewPartial
);
}
function onCopyNewPartial(err) {
if (err) {
console.error('Failed to delete previous main partial...');
return console.error(err);
}
console.log('Main partial copied...');
rmdir(
path.resolve(PISKELAPP_PATH, "static/editor/piskelapp-partials/"),
onDeleteTempPartial
);
}
function onDeleteTempPartial(err) {
if (err) {
console.error('Failed to delete temporary main partial...');
return console.error(err);
}
console.log('Temporary main partial deleted...');
fs.writeFile(path.resolve(PISKELAPP_PATH, "static/editor/VERSION"), pjson.version, onVersionFileCreated);
}
function onVersionFileCreated(err) {
if (err) {
console.error('Failed to create temporary main partial...');
return console.error(err);
}
console.log('Version file created...');
console.log('Finished!');
}
fse.copy(
path.resolve(PISKEL_PATH, "dest/prod"),
path.resolve(PISKELAPP_PATH, "static/editor"),
onCopy
);

11
nw.bld.js Normal file
View File

@ -0,0 +1,11 @@
const { nwbuild } = require("nw-builder");
nwbuild({
files: ["./dest/prod/**"],
version: "0.67.1",
flavor: "normal",
platforms: ["linux32", "linux64", "osx64", "win32", "win64"],
cacheDir: "./dest/desktop/cache",
buildDir: "./dest/desktop/build",
mode: "build",
});

9
nw.dev.js Normal file
View File

@ -0,0 +1,9 @@
const { nwbuild } = require("nw-builder");
nwbuild({
files: "./dest/prod/**",
version: "0.67.1",
flavor: "sdk",
cacheDir: "./dest/desktop/cache",
mode: "run",
});

14321
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -23,56 +23,49 @@
},
"main": "./dest/prod/index.html",
"scripts": {
"format": "grunt eslint --fix",
"test": "grunt test",
"dev": "grunt play",
"start": "grunt build && nw",
"preversion": "grunt test build",
"postversion": "git push && git push --tags && npm publish",
"release": "grunt && node ./bin/copy-to-piskel-website",
"build": "grunt desktop",
"build:mac": "grunt desktop-mac",
"format": "grunt eslint --fix"
"dev:website": "grunt play",
"dev:desktop": "node nw.dev.js",
"bld:website": "grunt default",
"bld:desktop": "node nw.bld.js"
},
"devDependencies": {
"dateformat": "4.5.1",
"fs-extra": "10.0.0",
"grunt": "1.4.1",
"grunt-casperjs": "^2.2.1",
"grunt-cli": "^1.4.3",
"grunt-contrib-clean": "2.0.0",
"grunt-contrib-concat": "1.0.1",
"@swc/cli": "0.1.57",
"@swc/core": "1.3.3",
"date-fns": "2.29.3",
"grunt": "1.5.3",
"grunt-casperjs": "2.2.1",
"grunt-cli": "1.4.3",
"grunt-contrib-clean": "2.0.1",
"grunt-contrib-concat": "2.1.0",
"grunt-contrib-connect": "3.0.0",
"grunt-contrib-copy": "1.0.0",
"grunt-contrib-jshint": "3.0.0",
"grunt-contrib-uglify": "5.0.1",
"grunt-contrib-watch": "^1.1.0",
"grunt-eslint": "23.0.0",
"grunt-contrib-jshint": "3.2.0",
"grunt-contrib-uglify": "5.2.2",
"grunt-contrib-watch": "1.1.0",
"grunt-eslint": "24.0.0",
"grunt-include-replace": "5.0.0",
"grunt-jscs": "3.0.1",
"grunt-karma": "4.0.2",
"grunt-leading-indent": "0.2.0",
"grunt-nw-builder": "3.1.0",
"grunt-replace": "2.0.2",
"grunt-spritesmith": "^6.9.0",
"jasmine-core": "3.8.0",
"karma": "6.3.4",
"karma-jasmine": "4.0.1",
"grunt-spritesmith": "6.10.0",
"jasmine-core": "4.4.0",
"karma": "6.4.1",
"karma-jasmine": "5.1.0",
"karma-phantomjs-launcher": "1.0.4",
"load-grunt-tasks": "5.1.0",
"nw": "0.54.0",
"phantomjs": "2.1.7",
"nw-builder": "3.8.6",
"phantomjs-polyfill-object-assign": "0.0.2",
"promise-polyfill": "8.2.0",
"rmdir": "1.2.0"
"phantomjs-prebuilt": "2.1.16",
"promise-polyfill": "8.2.3",
"vsx": "0.6.0"
},
"window": {
"title": "Piskel",
"icon": "dest/prod/logo.png",
"toolbar": false,
"width": 1000,
"height": 700
"icon": "dest/prod/logo.png"
},
"dependencies": {
"minimist": "^1.2.5"
"minimist": "1.2.6"
}
}

View File

@ -1,25 +0,0 @@
#!/bin/sh
# stash unstaged changes, run release task, stage release updates and restore stashed files
NAME=$(git branch | grep '*' | sed 's/* //')
# don't run on rebase
if [ $NAME != '(no branch)' ]
then
NOT_STAGED=$(git status | grep 'not staged')
# if [ "${NOT_STAGED#*not staged}" != "$NOT_STAGED" ]
if [ "$NOT_STAGED" != "" ]
then
echo "Unclean directory, aborting commit. Run git status."
exit 1
fi
grunt precommit
RETVAL=$?
if [ $RETVAL -ne 0 ]
then
echo "grunt test failed, aborting commit. Run grunt test"
exit 1
fi
fi

9
src/package.json Normal file
View File

@ -0,0 +1,9 @@
{
"name": "piskel-unleashed",
"version": "0.15.2",
"main": "./index.html",
"window": {
"title": "Piskel",
"icon": "./logo.png"
}
}