ripple 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/package.json +56 -24
- package/src/ai.js +292 -0
- package/src/compiler/errors.js +26 -0
- package/src/compiler/index.js +26 -0
- package/src/compiler/phases/1-parse/index.js +543 -0
- package/src/compiler/phases/1-parse/style.js +566 -0
- package/src/compiler/phases/2-analyze/index.js +509 -0
- package/src/compiler/phases/2-analyze/prune.js +572 -0
- package/src/compiler/phases/3-transform/index.js +1572 -0
- package/src/compiler/phases/3-transform/segments.js +91 -0
- package/src/compiler/phases/3-transform/stylesheet.js +372 -0
- package/src/compiler/scope.js +421 -0
- package/src/compiler/utils.js +552 -0
- package/src/constants.js +4 -0
- package/src/jsx-runtime.d.ts +94 -0
- package/src/jsx-runtime.js +46 -0
- package/src/runtime/array.js +215 -0
- package/src/runtime/index.js +39 -0
- package/src/runtime/internal/client/blocks.js +247 -0
- package/src/runtime/internal/client/constants.js +23 -0
- package/src/runtime/internal/client/events.js +223 -0
- package/src/runtime/internal/client/for.js +388 -0
- package/src/runtime/internal/client/if.js +35 -0
- package/src/runtime/internal/client/index.js +53 -0
- package/src/runtime/internal/client/operations.js +72 -0
- package/src/runtime/internal/client/portal.js +33 -0
- package/src/runtime/internal/client/render.js +156 -0
- package/src/runtime/internal/client/runtime.js +909 -0
- package/src/runtime/internal/client/template.js +51 -0
- package/src/runtime/internal/client/try.js +139 -0
- package/src/runtime/internal/client/utils.js +16 -0
- package/src/utils/ast.js +214 -0
- package/src/utils/builders.js +733 -0
- package/src/utils/patterns.js +23 -0
- package/src/utils/sanitize_template_string.js +7 -0
- package/test-mappings.js +0 -0
- package/types/index.d.ts +2 -0
- package/.npmignore +0 -2
- package/History.md +0 -3
- package/Readme.md +0 -151
- package/lib/exec/index.js +0 -60
- package/ripple.js +0 -645
package/ripple.js
DELETED
|
@@ -1,645 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/*!
|
|
3
|
-
* ripple.js
|
|
4
|
-
* Ripple
|
|
5
|
-
*
|
|
6
|
-
* Created by Carson Christian on 2011-12-28.
|
|
7
|
-
* Copyright 2011 Carson Christian <cc@amplego.com>
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var cli = require('commander'),
|
|
11
|
-
fs = require('fs'),
|
|
12
|
-
path = require('path'),
|
|
13
|
-
Exec = require('./lib/exec')(cli),
|
|
14
|
-
colors = require('colors');
|
|
15
|
-
|
|
16
|
-
var methods = {
|
|
17
|
-
file: {},
|
|
18
|
-
document: {}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
var properties = {
|
|
22
|
-
branch: {
|
|
23
|
-
execution: {
|
|
24
|
-
name: '',
|
|
25
|
-
isRelease: false,
|
|
26
|
-
isHotfix: false,
|
|
27
|
-
dirty: undefined
|
|
28
|
-
},
|
|
29
|
-
release: {
|
|
30
|
-
name: '',
|
|
31
|
-
exists: false
|
|
32
|
-
},
|
|
33
|
-
hotfix: {
|
|
34
|
-
name: '',
|
|
35
|
-
exists: false
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
document: {
|
|
39
|
-
version: {
|
|
40
|
-
from: '',
|
|
41
|
-
to: ''
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
repository: {
|
|
45
|
-
initialized: false
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Methods
|
|
50
|
-
/**
|
|
51
|
-
* checkLive
|
|
52
|
-
*
|
|
53
|
-
* Check that a git repository exists in good standing to execute this command.
|
|
54
|
-
*
|
|
55
|
-
* @param {Boolean} gentle - If true, do not process.exit on not exist, just return false.
|
|
56
|
-
*/
|
|
57
|
-
methods.checkLive = function (gentle) {
|
|
58
|
-
if (!gentle && !properties.repository.initialized) {
|
|
59
|
-
console.log('error: '.red.bold + 'git says this isn\'t a repository. Are you in the right folder?');
|
|
60
|
-
console.log(' If you would like to start a new repository here, use "ripple init <name> [version]" instead.');
|
|
61
|
-
process.exit(1);
|
|
62
|
-
} else {
|
|
63
|
-
return properties.repository.initialized;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* read
|
|
69
|
-
*
|
|
70
|
-
* Read a json file at uri and pass it as an object.
|
|
71
|
-
*
|
|
72
|
-
* @param {String} uri
|
|
73
|
-
* @param {Function} next
|
|
74
|
-
*/
|
|
75
|
-
methods.file.read = function (uri, next) {
|
|
76
|
-
if (cli.debug) console.error('debug:'.grey.inverse + ' file.read "%s"', uri.bold);
|
|
77
|
-
fs.readFile(uri, 'utf8', function (e, data) {
|
|
78
|
-
if (e) {
|
|
79
|
-
console.error('error: '.red + '%s could not be read. File does not exist.', uri);
|
|
80
|
-
process.exit(1);
|
|
81
|
-
} else {
|
|
82
|
-
try {
|
|
83
|
-
data = JSON.parse(data);
|
|
84
|
-
} catch (e) {
|
|
85
|
-
console.error('error: '.red + '%s could not be parsed. Make sure it is a valid json document.', uri);
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
next(data);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* write
|
|
95
|
-
*
|
|
96
|
-
* Write the passed object as a JSON file to the provided uri.
|
|
97
|
-
*
|
|
98
|
-
* @param {Object} doc
|
|
99
|
-
* @param {String} uri
|
|
100
|
-
* @param {Function} next
|
|
101
|
-
*/
|
|
102
|
-
methods.file.write = function (doc, uri, next) {
|
|
103
|
-
if (cli.debug) console.error('debug:'.grey.inverse + ' file.write "%s"', uri.bold);
|
|
104
|
-
fs.writeFile(uri, JSON.stringify(doc, null, 4), 'utf8', function (e) {
|
|
105
|
-
if (e) {
|
|
106
|
-
console.error('error: '.red + '%s could not be written.');
|
|
107
|
-
process.exit(1);
|
|
108
|
-
} else {
|
|
109
|
-
try {
|
|
110
|
-
next();
|
|
111
|
-
} catch (e) {}
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* read
|
|
118
|
-
*
|
|
119
|
-
* Read in the document, and update local variables.
|
|
120
|
-
*
|
|
121
|
-
* @param {String} branch - branch to checkout before reading
|
|
122
|
-
* @param {Function} next
|
|
123
|
-
*/
|
|
124
|
-
methods.document.read = function (branch, next) {
|
|
125
|
-
if (typeof branch !== 'string') throw new Error('Document: You must specify a branch to read package.json from.');
|
|
126
|
-
(new Exec()).send('git checkout ' + branch, function (e) {
|
|
127
|
-
if (e) {
|
|
128
|
-
console.log(e.message);
|
|
129
|
-
} else {
|
|
130
|
-
methods.file.read(path.resolve(cli.package), function (doc) {
|
|
131
|
-
properties.document.object = doc;
|
|
132
|
-
properties.document.version.to = doc.version.split('.').map(Number);
|
|
133
|
-
properties.document.version.from = properties.document.version.to.filter(function () { return true; }).join('.');
|
|
134
|
-
next();
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* write
|
|
142
|
-
*
|
|
143
|
-
* Write the document, and optionally commit.
|
|
144
|
-
*
|
|
145
|
-
* @param {Function} proceed
|
|
146
|
-
* @param {String} alias
|
|
147
|
-
*/
|
|
148
|
-
methods.document.write = function (proceed, alias) {
|
|
149
|
-
methods.file.write(properties.document.object, path.resolve(cli.package), function () {
|
|
150
|
-
if (cli.commit) {
|
|
151
|
-
console.log(' commiting changes'.blue);
|
|
152
|
-
(new Exec())
|
|
153
|
-
.send('git add ' + path.resolve(cli.package) + ' && git commit -m "bump version to ' + properties.document.object.version + '"', function (e, next, stdout) {
|
|
154
|
-
if (e) {
|
|
155
|
-
console.log(e.message);
|
|
156
|
-
} else {
|
|
157
|
-
console.log(stdout);
|
|
158
|
-
if (alias) {
|
|
159
|
-
// Rename branch
|
|
160
|
-
next();
|
|
161
|
-
} else {
|
|
162
|
-
try {
|
|
163
|
-
proceed();
|
|
164
|
-
} catch (e) {}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
.send('git branch -m ' + alias + '-' + properties.document.object.version, function (e) {
|
|
169
|
-
if (e) {
|
|
170
|
-
console.log(e.message);
|
|
171
|
-
} else {
|
|
172
|
-
try {
|
|
173
|
-
proceed();
|
|
174
|
-
} catch (e) {}
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
} else {
|
|
178
|
-
(new Exec())
|
|
179
|
-
.send('git add ' + path.resolve(cli.package) + ' && git status', function (e, next, stdout) {
|
|
180
|
-
if (e) {
|
|
181
|
-
console.log(e.message);
|
|
182
|
-
} else {
|
|
183
|
-
console.log(stdout);
|
|
184
|
-
try {
|
|
185
|
-
proceed();
|
|
186
|
-
} catch (e) {}
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* increment
|
|
195
|
-
*
|
|
196
|
-
* Increment the version number.
|
|
197
|
-
*
|
|
198
|
-
* @param {String} part
|
|
199
|
-
*/
|
|
200
|
-
methods.document.increment = function (part) {
|
|
201
|
-
if (part === 'revision') {
|
|
202
|
-
properties.document.version.to[2]++;
|
|
203
|
-
}
|
|
204
|
-
if (part === 'minor') {
|
|
205
|
-
properties.document.version.to[1]++;
|
|
206
|
-
properties.document.version.to[2] = 0;
|
|
207
|
-
}
|
|
208
|
-
if (part === 'major') {
|
|
209
|
-
properties.document.version.to[0]++;
|
|
210
|
-
properties.document.version.to[1] = 0;
|
|
211
|
-
properties.document.version.to[2] = 0;
|
|
212
|
-
}
|
|
213
|
-
console.log(' updating version: %s -> %s'.blue, properties.document.version.from, properties.document.version.to.join('.'));
|
|
214
|
-
properties.document.object.version = properties.document.version.to.join('.');
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Commands
|
|
219
|
-
*/
|
|
220
|
-
cli
|
|
221
|
-
.command('status')
|
|
222
|
-
.description(' Output current status of the active project.')
|
|
223
|
-
.action(function () {
|
|
224
|
-
methods.checkLive();
|
|
225
|
-
methods.file.read(path.resolve(cli.package), function (doc) {
|
|
226
|
-
console.log('Status');
|
|
227
|
-
console.log(' Current release: %s %s', doc.name.blue, doc.version.blue);
|
|
228
|
-
console.log(' With a package located at: %s', path.resolve(cli.package).blue);
|
|
229
|
-
console.log(' Working tree is %s, current branch is %s.', properties.branch.execution.dirty ? 'dirty'.underline : 'clean', properties.branch.execution.name.blue);
|
|
230
|
-
if (!properties.branch.execution.dirty) {
|
|
231
|
-
console.log(properties.branch.release.exists ? ' You cannot create a release branch, one already exists.' : ' You may create a release branch with "' + 'ripple start release bump <major/minor/revision>'.bold + '"');
|
|
232
|
-
console.log(properties.branch.hotfix.exists ? ' You cannot create a hotfix branch, one already exists.' : ' You may create a hotfix branch with "' + 'ripple start hotfix'.bold + '"');
|
|
233
|
-
}
|
|
234
|
-
console.log('ok.'.green.bold);
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
cli
|
|
238
|
-
.command('start <type> [name]')
|
|
239
|
-
.description(' Create a new branch of type "feature", "release", or "hotfix".\n If it\'s a feature branch, provide a name.')
|
|
240
|
-
.action(function (type, name) {
|
|
241
|
-
methods.checkLive();
|
|
242
|
-
console.log('Starting %s branch', type);
|
|
243
|
-
if (properties.branch.execution.dirty && type !== 'feature') {
|
|
244
|
-
console.log('error: '.red.bold + 'Can\'t start on a dirty working tree. Stash or commit your changes, then try again.');
|
|
245
|
-
process.exit(0);
|
|
246
|
-
}
|
|
247
|
-
if (type === 'feature') {
|
|
248
|
-
if (typeof name !== 'string') {
|
|
249
|
-
console.log('error: '.red.bold + 'When starting a new feature, include a name. i.e. "ripple start feature my_feature".');
|
|
250
|
-
process.exit(1);
|
|
251
|
-
}
|
|
252
|
-
if (properties.branch.execution.isRelease || properties.branch.execution.isHotfix || properties.branch.execution.name === 'master') {
|
|
253
|
-
console.log('error: '.red.bold + 'New features must be started relative to "develop", or an existing feature branch.');
|
|
254
|
-
process.exit(1);
|
|
255
|
-
}
|
|
256
|
-
methods.document.read(properties.branch.execution.name, function () {
|
|
257
|
-
console.log(' creating new %s branch from "%s"'.blue, name, properties.branch.execution.name);
|
|
258
|
-
(new Exec()).send('git checkout -b ' + name + ' ' + properties.branch.execution.name, function (e) {
|
|
259
|
-
if (e) {
|
|
260
|
-
console.log(e.message);
|
|
261
|
-
} else {
|
|
262
|
-
console.log('ok.'.green.bold);
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
} else if (type === 'release') {
|
|
267
|
-
if (properties.branch.release.exists) {
|
|
268
|
-
console.log('error: '.red.bold + 'You already have a release branch!');
|
|
269
|
-
process.exit(1);
|
|
270
|
-
}
|
|
271
|
-
methods.document.read('develop', function () {
|
|
272
|
-
console.log(' creating new release branch from "develop"'.blue);
|
|
273
|
-
methods.document.increment('revision');
|
|
274
|
-
if (properties.branch.hotfix.exists) {
|
|
275
|
-
console.log('warning'.red + ': A hotfix branch exists. You must finish the hotfix before finalizing the release.');
|
|
276
|
-
}
|
|
277
|
-
(new Exec()).send('git checkout -b release-' + properties.document.object.version + ' develop', function (e) {
|
|
278
|
-
if (e) {
|
|
279
|
-
console.log(e.message);
|
|
280
|
-
} else {
|
|
281
|
-
methods.document.write(function () {
|
|
282
|
-
console.log('ok.'.green.bold);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
} else if (type === 'hotfix') {
|
|
288
|
-
if (properties.branch.hotfix.exists) {
|
|
289
|
-
console.log('error: '.red.bold + 'You already have a hotfix branch!');
|
|
290
|
-
process.exit(1);
|
|
291
|
-
}
|
|
292
|
-
methods.document.read('master', function (doc) {
|
|
293
|
-
// *** hotfixes imply a revision bump only. Ignore version bump flags
|
|
294
|
-
console.log(' creating new hotfix branch from "master"'.blue);
|
|
295
|
-
methods.document.increment('revision');
|
|
296
|
-
if (properties.branch.release.exists) {
|
|
297
|
-
console.log('warning'.red + ': A release branch exists. You must finish the hotfix before finalizing the release.');
|
|
298
|
-
}
|
|
299
|
-
(new Exec()).send('git checkout -b hotfix-' + properties.document.object.version + ' master', function (e) {
|
|
300
|
-
if (e) {
|
|
301
|
-
console.log(e.message);
|
|
302
|
-
} else {
|
|
303
|
-
methods.document.write(function () {
|
|
304
|
-
console.log('ok.'.green.bold);
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
cli
|
|
312
|
-
.command('bump <part>')
|
|
313
|
-
.description(' Bump version number while on a release branch.\n Specify "major", "minor", or "revision".')
|
|
314
|
-
.action(function (part) {
|
|
315
|
-
methods.checkLive();
|
|
316
|
-
console.log('Bumping version number');
|
|
317
|
-
if (!properties.branch.execution.isRelease) {
|
|
318
|
-
console.log('error: '.red.bold + 'You can only manually bump versions on a release branch.');
|
|
319
|
-
process.exit(1);
|
|
320
|
-
}
|
|
321
|
-
methods.document.read(properties.branch.release.name, function () {
|
|
322
|
-
methods.document.increment(part);
|
|
323
|
-
methods.document.write(function () {
|
|
324
|
-
console.log('ok.'.green.bold);
|
|
325
|
-
}, 'release');
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
cli
|
|
329
|
-
.command('finish <type>')
|
|
330
|
-
.description(' Finish and merge the current release or hotfix branch.\n Specify "feature", "release", or "hotfix".' + '\n ' + 'Always commits!'.underline)
|
|
331
|
-
.action(function (type) {
|
|
332
|
-
methods.checkLive();
|
|
333
|
-
console.log('Finishing %s branch', type);
|
|
334
|
-
if (properties.branch.execution.dirty) {
|
|
335
|
-
console.log('error: '.red.bold + 'Can\'t start on a dirty working tree. Stash or commit your changes, then try again.');
|
|
336
|
-
process.exit(0);
|
|
337
|
-
}
|
|
338
|
-
if (properties.branch.release.exists && properties.branch.hotfix.exists && type === 'release') {
|
|
339
|
-
console.log('error: '.red.bold + 'You must finish your hotfix before finishing your release.');
|
|
340
|
-
process.exit(1);
|
|
341
|
-
}
|
|
342
|
-
if (type === 'feature' && (properties.branch.execution.isRelease || properties.branch.execution.isHotfix || properties.branch.execution.name === 'master' || properties.branch.execution.name === 'develop')) {
|
|
343
|
-
console.log('error: '.red.bold + 'Finishing a feature requires that you have it\'s branch already checked out.');
|
|
344
|
-
process.exit(1);
|
|
345
|
-
}
|
|
346
|
-
if (type === 'feature') {
|
|
347
|
-
// Feature integration
|
|
348
|
-
// merge feature into develop, delete feature
|
|
349
|
-
(new Exec())
|
|
350
|
-
.send('git checkout develop', function (e, next) {
|
|
351
|
-
if (e) {
|
|
352
|
-
console.log(e.message);
|
|
353
|
-
} else {
|
|
354
|
-
console.log(' merging %s into develop'.blue, properties.branch.execution.name);
|
|
355
|
-
next();
|
|
356
|
-
}
|
|
357
|
-
})
|
|
358
|
-
.send('git merge --no-ff ' + properties.branch.execution.name, function (e, next, stdout) {
|
|
359
|
-
if (e) {
|
|
360
|
-
console.log(stdout);
|
|
361
|
-
} else {
|
|
362
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
363
|
-
console.log(' removing %s branch'.blue, properties.branch.execution.name);
|
|
364
|
-
next();
|
|
365
|
-
}
|
|
366
|
-
})
|
|
367
|
-
.send('git branch -d ' + properties.branch.execution.name, function (e, next, stdout) {
|
|
368
|
-
if (e) {
|
|
369
|
-
console.log(e.message);
|
|
370
|
-
} else {
|
|
371
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
372
|
-
console.log('ok.'.green.bold);
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
} else if (type === 'release') {
|
|
376
|
-
// Release integration
|
|
377
|
-
// merge release into master, merge release into develop, delete release
|
|
378
|
-
methods.document.read(properties.branch.release.name, function () {
|
|
379
|
-
(new Exec())
|
|
380
|
-
.send('git checkout master', function (e, next) {
|
|
381
|
-
if (e) {
|
|
382
|
-
console.log(e.message);
|
|
383
|
-
} else {
|
|
384
|
-
console.log(' merging %s into master'.blue, properties.branch.release.name);
|
|
385
|
-
next();
|
|
386
|
-
}
|
|
387
|
-
})
|
|
388
|
-
.send('git merge --no-ff -s recursive -Xtheirs ' + properties.branch.release.name, function (e, next, stdout) {
|
|
389
|
-
if (e) {
|
|
390
|
-
console.log(stdout);
|
|
391
|
-
} else {
|
|
392
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
393
|
-
console.log(' tagging version %s on master'.blue, properties.document.object.version);
|
|
394
|
-
next();
|
|
395
|
-
}
|
|
396
|
-
})
|
|
397
|
-
.send('git tag -a ' + properties.document.object.version + ' -m "version ' + properties.document.object.version + '"', function (e, next) {
|
|
398
|
-
if (e) {
|
|
399
|
-
console.log(e.message);
|
|
400
|
-
} else {
|
|
401
|
-
next();
|
|
402
|
-
}
|
|
403
|
-
})
|
|
404
|
-
.send('git checkout develop', function (e, next) {
|
|
405
|
-
if (e) {
|
|
406
|
-
console.log(e.message);
|
|
407
|
-
} else {
|
|
408
|
-
console.log(' merging %s into develop'.blue, properties.branch.release.name);
|
|
409
|
-
next();
|
|
410
|
-
}
|
|
411
|
-
})
|
|
412
|
-
.send('git merge --no-ff ' + properties.branch.release.name, function (e, next, stdout) {
|
|
413
|
-
if (e) {
|
|
414
|
-
console.log('error: '.red.bold + 'Merge failed.');
|
|
415
|
-
console.log(stdout);
|
|
416
|
-
} else {
|
|
417
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
418
|
-
console.log(' removing %s branch'.blue, properties.branch.release.name);
|
|
419
|
-
next();
|
|
420
|
-
}
|
|
421
|
-
})
|
|
422
|
-
.send('git branch -d ' + properties.branch.release.name, function (e, next, stdout) {
|
|
423
|
-
if (e) {
|
|
424
|
-
console.log(e.message);
|
|
425
|
-
} else {
|
|
426
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
427
|
-
console.log('ok.'.green.bold);
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
});
|
|
431
|
-
} else if (type === 'hotfix') {
|
|
432
|
-
// Hotfix integration
|
|
433
|
-
// checkout master, merge in hotfix, checkout develop, merge in hotfix, delete hotfix
|
|
434
|
-
methods.document.read(properties.branch.hotfix.name, function () {
|
|
435
|
-
(new Exec())
|
|
436
|
-
.send('git checkout master', function (e, next) {
|
|
437
|
-
if (e) {
|
|
438
|
-
console.log(e.message);
|
|
439
|
-
} else {
|
|
440
|
-
console.log(' merging %s into master'.blue, properties.branch.hotfix.name);
|
|
441
|
-
next();
|
|
442
|
-
}
|
|
443
|
-
})
|
|
444
|
-
.send('git merge --no-ff -s recursive -Xtheirs ' + properties.branch.hotfix.name, function (e, next, stdout) {
|
|
445
|
-
if (e) {
|
|
446
|
-
console.log(stdout);
|
|
447
|
-
} else {
|
|
448
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
449
|
-
console.log(' tagging version %s on master'.blue, properties.document.object.version);
|
|
450
|
-
next();
|
|
451
|
-
}
|
|
452
|
-
})
|
|
453
|
-
.send('git tag -a ' + properties.document.object.version + ' -m "version ' + properties.document.object.version + '"', function (e) {
|
|
454
|
-
if (e) {
|
|
455
|
-
console.log(e.message);
|
|
456
|
-
} else {
|
|
457
|
-
if (properties.branch.release.exists) {
|
|
458
|
-
// Merge into release
|
|
459
|
-
(new Exec())
|
|
460
|
-
.send('git checkout ' + properties.branch.release.name, function (e, next) {
|
|
461
|
-
if (e) {
|
|
462
|
-
console.log(e.message);
|
|
463
|
-
} else {
|
|
464
|
-
console.log((' merging %s into ' + properties.branch.release.name).blue, properties.branch.hotfix.name);
|
|
465
|
-
next();
|
|
466
|
-
}
|
|
467
|
-
})
|
|
468
|
-
.send('git merge --no-ff -s recursive -Xtheirs ' + properties.branch.hotfix.name, function (e, next, stdout) {
|
|
469
|
-
if (e) {
|
|
470
|
-
console.log(stdout);
|
|
471
|
-
} else {
|
|
472
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
473
|
-
console.log('warning'.red + ': Check the results of this merge carfully! Conflicts may be auto-resolved using hotfix.');
|
|
474
|
-
console.log(' removing %s branch'.blue, properties.branch.hotfix.name);
|
|
475
|
-
next();
|
|
476
|
-
}
|
|
477
|
-
})
|
|
478
|
-
.send('git branch -d ' + properties.branch.hotfix.name, function (e, next, stdout) {
|
|
479
|
-
if (e) {
|
|
480
|
-
console.log(e.message);
|
|
481
|
-
} else {
|
|
482
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
483
|
-
console.log(' auto-incrementing release branch'.blue);
|
|
484
|
-
console.log('note'.underline + ': if you would prefer a different release version, run "ripple bump <major/minor/revision>".');
|
|
485
|
-
methods.document.increment('revision');
|
|
486
|
-
methods.document.write(function () {
|
|
487
|
-
console.log('ok.'.green.bold);
|
|
488
|
-
}, 'release');
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
} else {
|
|
492
|
-
// Merge into develop
|
|
493
|
-
(new Exec())
|
|
494
|
-
.send('git checkout develop', function (e, next) {
|
|
495
|
-
if (e) {
|
|
496
|
-
console.log(e.message);
|
|
497
|
-
} else {
|
|
498
|
-
console.log(' merging %s into develop'.blue, properties.branch.hotfix.name);
|
|
499
|
-
next();
|
|
500
|
-
}
|
|
501
|
-
})
|
|
502
|
-
.send('git merge --no-ff ' + properties.branch.hotfix.name, function (e, next, stdout) {
|
|
503
|
-
if (e) {
|
|
504
|
-
console.log(stdout);
|
|
505
|
-
} else {
|
|
506
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
507
|
-
console.log(' removing %s branch'.blue, properties.branch.hotfix.name);
|
|
508
|
-
next();
|
|
509
|
-
}
|
|
510
|
-
})
|
|
511
|
-
.send('git branch -d ' + properties.branch.hotfix.name, function (e, next, stdout) {
|
|
512
|
-
if (e) {
|
|
513
|
-
console.log(e.message);
|
|
514
|
-
} else {
|
|
515
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
516
|
-
console.log('ok.'.green.bold);
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
cli
|
|
526
|
-
.command('init <name> [version]')
|
|
527
|
-
.description(' Initialize a ripple project here (creating a repository if needed), with the given project name and version number. [0.0.1]')
|
|
528
|
-
.action(function (name, version) {
|
|
529
|
-
version = version || '0.0.1';
|
|
530
|
-
if (version.split('.').length !== 3) {
|
|
531
|
-
console.log('error: '.red.bold + 'Version numbers must follow the major.minor.revision convention. i.e. 1.0.0');
|
|
532
|
-
process.exit(1);
|
|
533
|
-
}
|
|
534
|
-
fs.readFile(path.resolve(cli.package), 'utf8', function (e, data) {
|
|
535
|
-
if (e) {
|
|
536
|
-
// Package doesn't exist ... expected
|
|
537
|
-
console.log('Initializing new ripple project');
|
|
538
|
-
if (!methods.checkLive(true)) {
|
|
539
|
-
// No git repo yet
|
|
540
|
-
console.log(' creating new git repository where there was none');
|
|
541
|
-
(new Exec())
|
|
542
|
-
.send('git init', function (e, next) {
|
|
543
|
-
console.log(' creating new package.json on "master" for project %s version %s', name.blue, version.blue);
|
|
544
|
-
fs.writeFile(path.resolve(cli.package), JSON.stringify({ name: name, version: version }, null, 4), 'utf8', function (err) {
|
|
545
|
-
if (err) {
|
|
546
|
-
console.error('error: '.red + '%s could not be written.');
|
|
547
|
-
process.exit(1);
|
|
548
|
-
} else {
|
|
549
|
-
console.log(' commiting package.json');
|
|
550
|
-
console.log(' creating new "develop" branch');
|
|
551
|
-
next();
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
})
|
|
555
|
-
.send('git add ./package.json && git commit -m "create new package.json for ' + name + ' version ' + version + '" && git checkout -b develop', function (e, next, stdout) {
|
|
556
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
557
|
-
console.log('ok.'.green.bold);
|
|
558
|
-
});
|
|
559
|
-
} else {
|
|
560
|
-
// Existing git repo
|
|
561
|
-
(new Exec())
|
|
562
|
-
.send('git checkout -b master || git checkout master', function (e, next, stdout) {
|
|
563
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
564
|
-
console.log(' creating new package.json on "master" for project %s version %s', name.blue, version.blue);
|
|
565
|
-
fs.writeFile(path.resolve(cli.package), JSON.stringify({ name: name, version: version }, null, 4), 'utf8', function (err) {
|
|
566
|
-
if (err) {
|
|
567
|
-
console.error('error: '.red + '%s could not be written.');
|
|
568
|
-
process.exit(1);
|
|
569
|
-
} else {
|
|
570
|
-
console.log(' creating new "develop" branch');
|
|
571
|
-
console.log(' commiting package.json');
|
|
572
|
-
next();
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
})
|
|
576
|
-
.send('git checkout -b develop && git add ./package.json && git commit -m "create new package.json for ' + name + ' version ' + version + '" && git checkout master && git merge --no-ff develop && git checkout develop', function (e, next, stdout) {
|
|
577
|
-
if (cli.verbose) console.log(stdout.grey);
|
|
578
|
-
console.log('ok.'.green.bold);
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
} else {
|
|
582
|
-
try {
|
|
583
|
-
data = JSON.parse(data);
|
|
584
|
-
console.log('error: '.red.bold + 'An existing package.json file was found, describing this project as %s with version %s.', data.name.blue, data.version.blue);
|
|
585
|
-
process.exit(1);
|
|
586
|
-
} catch (e) {
|
|
587
|
-
console.log('error: '.red.bold + 'An existing package.json file was found, but could not be parsed. Either fix it manually, or remove it and re-execute "ripple init".');
|
|
588
|
-
process.exit(1);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
cli
|
|
594
|
-
.command('*')
|
|
595
|
-
.action(function () {
|
|
596
|
-
(new Exec()).send('ripple --help', function (e, next, stdout) {
|
|
597
|
-
console.log(stdout);
|
|
598
|
-
});
|
|
599
|
-
});
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Options
|
|
603
|
-
*/
|
|
604
|
-
cli
|
|
605
|
-
.option('-p, --package <location>', 'Relative path of package.json file to modify [./package.json]', './package.json')
|
|
606
|
-
.option('-x, --no-commit', 'Do not commit version changes automatically')
|
|
607
|
-
.option('-d, --debug', 'show debug output')
|
|
608
|
-
.option('-v, --verbose', 'show verbose git output');
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* Preload all state info.
|
|
612
|
-
*/
|
|
613
|
-
(new Exec())
|
|
614
|
-
.send('git status', function (e, next, stdout, stderr) {
|
|
615
|
-
properties.repository.initialized = stderr.indexOf('fatal') === -1;
|
|
616
|
-
next();
|
|
617
|
-
})
|
|
618
|
-
.send('git status|grep -c "working directory clean"', function (e, next, stdout) {
|
|
619
|
-
properties.branch.execution.dirty = stdout.trim() === '0';
|
|
620
|
-
next();
|
|
621
|
-
})
|
|
622
|
-
.send('git branch --no-color|sed -e "/^[^*]/d" -e "s/* \(.*\)/\ \1/"', function (e, next, stdout) {
|
|
623
|
-
properties.branch.execution.name = stdout.trim().slice(2);
|
|
624
|
-
properties.branch.execution.isRelease = properties.branch.execution.name.indexOf('release') !== -1;
|
|
625
|
-
properties.branch.execution.isHotfix = properties.branch.execution.name.indexOf('hotfix') !== -1;
|
|
626
|
-
next();
|
|
627
|
-
})
|
|
628
|
-
.send('git branch|grep release', function (e, next, stdout) {
|
|
629
|
-
properties.branch.release.exists = stdout.trim().length > 0;
|
|
630
|
-
properties.branch.release.name = stdout.trim();
|
|
631
|
-
if (properties.branch.release.name.indexOf('*') !== -1) {
|
|
632
|
-
// Trim possible leading '* '
|
|
633
|
-
properties.branch.release.name = properties.branch.release.name.slice(2);
|
|
634
|
-
}
|
|
635
|
-
next();
|
|
636
|
-
})
|
|
637
|
-
.send('git branch|grep hotfix', function (e, next, stdout) {
|
|
638
|
-
properties.branch.hotfix.exists = stdout.trim().length > 0;
|
|
639
|
-
properties.branch.hotfix.name = stdout.trim();
|
|
640
|
-
if (properties.branch.hotfix.name.indexOf('*') !== -1) {
|
|
641
|
-
// Trim possible leading '* '
|
|
642
|
-
properties.branch.hotfix.name = properties.branch.hotfix.name.slice(2);
|
|
643
|
-
}
|
|
644
|
-
cli.parse(process.argv);
|
|
645
|
-
});
|