Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
klembot committed Mar 2, 2017
2 parents 5a645cb + 391f1d3 commit 2eb49d6
Show file tree
Hide file tree
Showing 41 changed files with 3,747 additions and 2,032 deletions.
1 change: 1 addition & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ cache
dist-apps
build
nw-cache
nwbuilder-cache
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ Run `npm start` to begin serving a development version of Twine to
http://localhost:8080. This server will automatically update with changes you
make. You can also create a dev build at `build/` with `npm run build`.

`npm lint` and `npm test` will lint and test the source code respectively.
`npm run lint` and `npm test` will lint and test the source code respectively.

`npm pot` will create a POT template file for localization at
`npm run pot` will create a POT template file for localization at
`src/locale/po/template.pot`. See Localization below for more information.

`npm nw` will build NW.js-based apps in `dist/nw`. In order to build Windows
`npm run nw` will build NW.js-based apps in `dist/nw`. In order to build Windows
apps on OS X or Linux, you will need to have [Wine](https://www.winehq.org/)
and [makensis](http://nsis.sourceforge.net/) installed.

Expand Down
12 changes: 3 additions & 9 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
'use strict';
let webpackConfig = require('./webpack.config.js');

/*
Clear entry point re:
http://mike-ward.net/2015/09/07/tips-on-setting-up-karma-testing-with-webpack/.
*/

webpackConfig.entry = {};

/* Add Babel loader since PhantomJS doesn't speak ES6. */

webpackConfig.module.loaders.push({
webpackConfig.module.rules.push({
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
options: {
presets: ['es2015']
}
});
Expand All @@ -25,6 +18,7 @@ module.exports = function(config) {
files: ['src/**/*.spec.js'],
frameworks: ['mocha'],
preprocessors: { 'src/**/*.spec.js': ['webpack'] },
reporters: ['mocha'],
singleRun: true,
webpack: webpackConfig,
webpackMiddleware: { noInfo: true }
Expand Down
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Twine",
"version": "2.1.0",
"version": "2.1.1",
"author": "Chris Klimas <[email protected]>",
"description": "a GUI for creating nonlinear stories",
"license": "GPL-3.0",
Expand All @@ -18,9 +18,9 @@
},
"scripts": {
"build": "webpack -d --progress",
"build:release": "webpack -p --progress --config webpack.config.release.js; webpack -p --progress --config webpack.config.cdn.js",
"build:release": "webpack -p --progress --config webpack.config.release.js && webpack -p --progress --config webpack.config.cdn.js",
"clean": "rimraf build/ dist/",
"lint": "eslint src/; jscs src/; exit 0",
"lint": "eslint src/ && jscs src/ || exit 0",
"nw": "node scripts/build-nw.js",
"package": "npm run build:release && npm run nw && node scripts/package.js",
"pot": "node scripts/extract-pot.js",
Expand All @@ -29,16 +29,20 @@
"watch": "webpack -d --progress --watch"
},
"dependencies": {
"babel-loader": "^6.2.10",
"blob-polyfill": "^1.0.20150320",
"browser-saveas": "^1.0.0",
"codemirror": "^5.5.0",
"core-js": "^2.4.0",
"dom-event-special": "^0.1.7",
"ejs-html-loader": "^2.0.2",
"extract-text-webpack-plugin": "^2.0.0-rc.3",
"fastclick": "^1.0.6",
"font-awesome": "^4.3.0",
"html-webpack-plugin": "^2.28.0",
"jed": "^1.1.0",
"jquery": "^2.1.4",
"jszip": "^2.5.0",
"karma-webpack": "^1.8.1",
"mkdirp": "^0.5.1",
"moment": "^2.10.3",
"osenv": "^0.1.3",
Expand All @@ -51,7 +55,9 @@
"underscore": "^1.8.3",
"vue": "^1.0.18",
"vue-router": "^0.7.13",
"vuex": "^0.6.3"
"vuex": "^0.6.3",
"webpack": "^2.2.1",
"webpack-dev-server": "^1.16.3"
},
"devDependencies": {
"acorn": "^4.0.3",
Expand Down Expand Up @@ -79,12 +85,14 @@
"karma": "^1.3.0",
"karma-cli": "^1.0.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-webpack": "^1.8.0",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"less-plugin-autoprefix": "^1.5.1",
"less-plugin-clean-css": "^1.5.1",
"mocha": "^3.2.0",
"nw-builder": "^3.1.2",
"po2json": "^0.4.5",
"pofile": "^1.0.2",
Expand All @@ -93,7 +101,7 @@
"sinon": "^2.0.0-pre.4",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.3",
"webpack": "^2.2.0",
"webpack-dev-server": "^1.16.2",
"yargs": "^6.6.0"
}
Expand Down
98 changes: 86 additions & 12 deletions src/data/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const actions = module.exports = {
*/

const oldNameEscaped = oldName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const newNameEscaped = newName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const newNameEscaped = newName.replace(/\$/g, '$$$$');

const simpleLinkRe = new RegExp(
'\\[\\[' + oldNameEscaped + '(\\]\\[.*?)?\\]\\]',
Expand Down Expand Up @@ -256,14 +256,42 @@ const actions = module.exports = {
crossDomain: true
})
.done(props => {
if (store.state.storyFormat.formats.some(
format => format.name === props.name)) {
const pVer = semverUtils.parse(props.version);
const pMinor = parseInt(pVer.minor);
const pPatch = parseInt(pVer.patch);

/*
Check for an identical version.
*/

if (store.state.storyFormat.formats.some(current => {
return existing.version === props.version;
})) {
reject(new Error(
locale.say('this story format is already installed')
));
return;
}

/*
Check for a more recent version.
*/

if (store.state.storyFormat.formats.some(current => {
const cVer = semverUtils.parse(current.version);

return current.name === props.name &&
cVer.major === pVer.major &&
parseInt(cVer.minor) >= pMinor &&
parseInt(cVer.patch) >= pPatch;
})) {
reject(new Error(
locale.say(
'a story format named &ldquo;%s&rdquo; already exists',
'a more recent version of the story format &ldquo;%s&rdquo; is already installed',
props.name
)
));
return;
}

const format = {
Expand Down Expand Up @@ -300,15 +328,17 @@ const actions = module.exports = {

const format = formats.reduce((prev, current) => {
const pVer = semverUtils.parse(prev.version);
const pMinor = parseInt(pVer.minor);
const pPatch = parseInt(pVer.patch);
const cVer = semverUtils.parse(current.version);
const cMinor = parseInt(cVer.minor);
const cPatch = parseInt(cVer.patch);

if (cVer.major === pVer.major && (parseInt(cVer.minor) >
parseInt(pVer.minor) || parseInt(cVer.patch) >
parseInt(pVer.minor))) {
return current;
if (cMinor <= pMinor && cPatch <= pPatch) {
return prev;
}

return previous;
return current;
});

if (!format) {
Expand Down Expand Up @@ -391,8 +421,8 @@ const actions = module.exports = {
},
{
name: 'SugarCube',
url: 'story-formats/sugarcube-2.12.1/format.js',
version: '2.12.1',
url: 'story-formats/sugarcube-2.14.0/format.js',
version: '2.14.0',
userAdded: false
}
];
Expand Down Expand Up @@ -426,6 +456,50 @@ const actions = module.exports = {
{ name: 'Paperthin', version: '1.0.0' }
);
}

/*
Delete any outdated formats.
*/

const latestVersions = {};

store.state.storyFormat.formats.forEach(format => {
if (!format.version) {
return;
}

const v = semverUtils.parse(format.version);

if (latestVersions[format.name]) {
const existing = latestVersions[format.name][v.major];

if (!existing ||
v.minor > existing.minor ||
v.minor === existing.minor && v.patch > existing.patch) {
latestVersions[format.name][v.major] = v;
}
}
else {
latestVersions[format.name] = {};
latestVersions[format.name][v.major] = v;
}
});

store.state.storyFormat.formats.forEach(format => {
if (!format.version) {
return;
}

const v = semverUtils.parse(format.version);

if (v.version !== latestVersions[format.name][v.major].version) {
console.warn(
`Deleting outdated story format ${format.name} ` +
v.version
);
actions.deleteFormat(store, format.id);
}
});
},

/*
Expand Down Expand Up @@ -463,7 +537,7 @@ const actions = module.exports = {
actions.updateStory(
store,
story.id,
{ storyFormat: 'SugarCube', storyFormatVersion: '2.12.1' }
{ storyFormat: 'SugarCube', storyFormatVersion: '2.14.0' }
);
}
else if (!story.storyFormatVersion) {
Expand Down
Loading

0 comments on commit 2eb49d6

Please sign in to comment.