rock 0.4.0 → 0.9.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/README.md +51 -182
- package/dist/src/bin.d.ts +2 -0
- package/dist/src/bin.d.ts.map +1 -0
- package/dist/src/bin.js +7 -0
- package/dist/src/bin.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/adHocTemplates.d.ts +13 -0
- package/dist/src/lib/adHocTemplates.js +366 -0
- package/dist/src/lib/adHocTemplates.js.map +1 -0
- package/dist/src/lib/checkDeprecatedOptions.d.ts +1 -0
- package/dist/src/lib/checkDeprecatedOptions.d.ts.map +1 -0
- package/dist/src/lib/checkDeprecatedOptions.js +60 -0
- package/dist/src/lib/checkDeprecatedOptions.js.map +1 -0
- package/dist/src/lib/cli.d.ts +6 -0
- package/dist/src/lib/cli.d.ts.map +1 -0
- package/dist/src/lib/cli.js +101 -0
- package/dist/src/lib/cli.js.map +1 -0
- package/dist/src/lib/plugins/clean.d.ts +2 -0
- package/dist/src/lib/plugins/clean.d.ts.map +1 -0
- package/dist/src/lib/plugins/clean.js +317 -0
- package/dist/src/lib/plugins/clean.js.map +1 -0
- package/dist/src/lib/plugins/fingerprint.d.ts +12 -0
- package/dist/src/lib/plugins/fingerprint.d.ts.map +1 -0
- package/dist/src/lib/plugins/fingerprint.js +72 -0
- package/dist/src/lib/plugins/fingerprint.js.map +1 -0
- package/dist/src/lib/plugins/logConfig.d.ts +14 -0
- package/dist/src/lib/plugins/logConfig.d.ts.map +1 -0
- package/dist/src/lib/plugins/logConfig.js +54 -0
- package/dist/src/lib/plugins/logConfig.js.map +1 -0
- package/dist/src/lib/plugins/remoteCache.d.ts +2 -0
- package/dist/src/lib/plugins/remoteCache.d.ts.map +1 -0
- package/dist/src/lib/plugins/remoteCache.js +335 -0
- package/dist/src/lib/plugins/remoteCache.js.map +1 -0
- package/dist/src/lib/plugins/templateIndexHtml.d.ts +5 -0
- package/dist/src/lib/plugins/templateIndexHtml.js +189 -0
- package/dist/src/lib/plugins/templateIndexHtml.js.map +1 -0
- package/dist/src/lib/plugins/templateManifestPlist.d.ts +8 -0
- package/dist/src/lib/plugins/templateManifestPlist.js +36 -0
- package/dist/src/lib/plugins/templateManifestPlist.js.map +1 -0
- package/package.json +31 -50
- package/.npmignore +0 -1
- package/.travis.yml +0 -4
- package/CHANGELOG.md +0 -61
- package/LICENSE +0 -15
- package/bin/rock +0 -43
- package/docs/predefined-tokens.md +0 -31
- package/lib/rock.js +0 -213
- package/lib/tweezers.js +0 -37
- package/lib/util.js +0 -9
- package/test/mocha.opts +0 -3
- package/test/resources/expect/myapp/LICENSE +0 -15
- package/test/resources/expect/myapp/README.md +0 -17
- package/test/resources/expect/myapp/ignore_this/READTHIS.md +0 -1
- package/test/resources/expect/myapp/lib/cool_module.js +0 -4
- package/test/resources/expect/myapp/test/cool_module.test.js +0 -4
- package/test/resources/rock.conf.json +0 -3
- package/test/resources/rocks/date.txt +0 -1
- package/test/resources/rocks/literal-alt.txt +0 -1
- package/test/resources/rocks/literal.txt +0 -1
- package/test/resources/rocks/node-lib/.rock/rock.json +0 -9
- package/test/resources/rocks/node-lib/.rock/scripts/bye.js +0 -1
- package/test/resources/rocks/node-lib/.rock/scripts/hi.sh +0 -3
- package/test/resources/rocks/node-lib/LICENSE +0 -15
- package/test/resources/rocks/node-lib/README.md +0 -17
- package/test/resources/rocks/node-lib/ignore_this/READTHIS.md +0 -1
- package/test/resources/rocks/node-lib/lib/{{project-name}}.js +0 -4
- package/test/resources/rocks/node-lib/test/{{project-name}}.test.js +0 -4
- package/test/resources/rocks/node-lib-tmpl/.rock/rock.json +0 -13
- package/test/resources/rocks/node-lib-tmpl/.rock/scripts/bye.js +0 -1
- package/test/resources/rocks/node-lib-tmpl/.rock/scripts/hi.sh +0 -3
- package/test/resources/rocks/node-lib-tmpl/LICENSE +0 -15
- package/test/resources/rocks/node-lib-tmpl/README.md +0 -17
- package/test/resources/rocks/node-lib-tmpl/ignore_this/READTHIS.md +0 -1
- package/test/resources/rocks/node-lib-tmpl/lib/@@project-name@@.js +0 -4
- package/test/resources/rocks/node-lib-tmpl/test/@@project-name@@.test.js +0 -4
- package/test/rock-bin.test.js +0 -73
- package/test/rock-dload-github.test.js +0 -41
- package/test/rock-file.test.js +0 -47
- package/test/rock.predefined-locals.js +0 -52
- package/test/rock.test.js +0 -78
package/package.json
CHANGED
|
@@ -1,60 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rock",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"types": "./dist/src/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/src/index.d.ts",
|
|
9
|
+
"default": null
|
|
10
|
+
},
|
|
11
|
+
"./package.json": "./package.json"
|
|
8
12
|
},
|
|
9
|
-
"
|
|
10
|
-
"rock"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"template",
|
|
15
|
-
"scaffold"
|
|
13
|
+
"bin": {
|
|
14
|
+
"rock": "./dist/src/bin.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
16
18
|
],
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.lib.json",
|
|
21
|
+
"dev": "tsc -p tsconfig.lib.json --watch",
|
|
22
|
+
"publish:npm": "npm publish --access public",
|
|
23
|
+
"publish:verdaccio": "npm publish --registry http://localhost:4873 --userconfig ../../.npmrc"
|
|
24
|
+
},
|
|
19
25
|
"dependencies": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"osenv": "^0.1.3",
|
|
28
|
-
"path-exists": "^3.0.0",
|
|
29
|
-
"readline-prompter": "~0.2.0",
|
|
30
|
-
"string": "^3.3.1",
|
|
31
|
-
"superagent": "~0.14.1",
|
|
32
|
-
"tweezers": "~0.1.0",
|
|
33
|
-
"walker": "1.0.x"
|
|
26
|
+
"adm-zip": "^0.5.16",
|
|
27
|
+
"@react-native-community/cli-config": "^19.1.0",
|
|
28
|
+
"@rock-js/config": "^0.9.0",
|
|
29
|
+
"@rock-js/tools": "^0.9.0",
|
|
30
|
+
"commander": "^12.1.0",
|
|
31
|
+
"tar": "^7.4.3",
|
|
32
|
+
"tslib": "^2.3.0"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"standard": "^8.0.0",
|
|
39
|
-
"suppose": "^0.6.1",
|
|
40
|
-
"terst": "^0.3.0",
|
|
41
|
-
"testutil": "^0.7.0"
|
|
42
|
-
},
|
|
43
|
-
"main": "./lib/rock",
|
|
44
|
-
"scripts": {
|
|
45
|
-
"test": "standard && mocha test"
|
|
46
|
-
},
|
|
47
|
-
"bin": {
|
|
48
|
-
"rock": "./bin/rock"
|
|
35
|
+
"@react-native-community/cli-types": "^19.1.0",
|
|
36
|
+
"@types/adm-zip": "^0.5.7"
|
|
49
37
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"T",
|
|
53
|
-
"F",
|
|
54
|
-
"EQ",
|
|
55
|
-
"NEQ",
|
|
56
|
-
"APPROX",
|
|
57
|
-
"THROWS"
|
|
58
|
-
]
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
59
40
|
}
|
|
60
41
|
}
|
package/.npmignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
node_modules/
|
package/.travis.yml
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
0.3.1 / 2013-10-30
|
|
2
|
-
------------------
|
|
3
|
-
* removed `preferGlobal`
|
|
4
|
-
* added `cl` require to `rock` bin (tayler / #10)
|
|
5
|
-
|
|
6
|
-
0.3.0 / 2013-05-02
|
|
7
|
-
------------------
|
|
8
|
-
* added `cl` dep
|
|
9
|
-
* updated deps
|
|
10
|
-
* renamed `create()` to `fetchRepo()`
|
|
11
|
-
* added ability to download single files
|
|
12
|
-
* added rudimentary support for other templates
|
|
13
|
-
|
|
14
|
-
0.2.0 / 2013-01-21
|
|
15
|
-
------------------
|
|
16
|
-
* Updated deps.
|
|
17
|
-
* Removed post-install script.
|
|
18
|
-
* Removed `--update` and `--list` flags.
|
|
19
|
-
* Support installing from Github without Git dependency.
|
|
20
|
-
* Support installing from Github using Github short-hand i.e. username/repo
|
|
21
|
-
* Added default values to skip and prompt.
|
|
22
|
-
* Changed config file name from `rockconf.json` to `rock.conf.json`.
|
|
23
|
-
|
|
24
|
-
0.1.1 / 2012-09-06
|
|
25
|
-
------------------
|
|
26
|
-
* Dependencies update.
|
|
27
|
-
|
|
28
|
-
0.1.0 / 2012-08-15
|
|
29
|
-
------------------
|
|
30
|
-
* Git not necessary for Rock located on the local machine. This helps with the programmability aspect.
|
|
31
|
-
* Code cleanup using `BatchFlow` and `readline-prompter`.
|
|
32
|
-
* `rock.create` now can take an input of values so that the the readline prompt doesn't display. Test passing.
|
|
33
|
-
|
|
34
|
-
0.0.7 / 2012-08-13
|
|
35
|
-
------------------
|
|
36
|
-
* Fixed bug that prevented rocks without `ignoreDirs` to be created.
|
|
37
|
-
|
|
38
|
-
0.0.6 / 2012-08-13
|
|
39
|
-
------------------
|
|
40
|
-
* Added `--update` command line arg.
|
|
41
|
-
* Now proceeds regardless of whether it can parse `rockconf.json`.
|
|
42
|
-
|
|
43
|
-
0.0.5 / 2012-08-12
|
|
44
|
-
------------------
|
|
45
|
-
* Fixed crashed on `rock --list`.
|
|
46
|
-
|
|
47
|
-
0.0.4 / 2012-08-12
|
|
48
|
-
------------------
|
|
49
|
-
* Rocks can now specify to have directories ignored by putting `ignoreDirs` in their `rock.json` file.
|
|
50
|
-
|
|
51
|
-
0.0.3 / 2012-08-11
|
|
52
|
-
------------------
|
|
53
|
-
* Fixed bug preventing rock from shutting down when using programatically.
|
|
54
|
-
|
|
55
|
-
0.0.2 / 2012-08-09
|
|
56
|
-
------------------
|
|
57
|
-
* Hopefully fixing early broken release.
|
|
58
|
-
|
|
59
|
-
0.0.1 / 2012-08-09
|
|
60
|
-
------------------
|
|
61
|
-
* Very early alpha release.
|
package/LICENSE
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
(The MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2012-2013, JP Richardson
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
|
6
|
-
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
|
7
|
-
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
13
|
-
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
|
14
|
-
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
15
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/bin/rock
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
var P = require('autoresolve')
|
|
4
|
-
var rock = require(P('lib/rock.js'))
|
|
5
|
-
var osenv = require('osenv')
|
|
6
|
-
var fs = require('fs-promise')
|
|
7
|
-
var path = require('path')
|
|
8
|
-
var nom = require('nomnom')
|
|
9
|
-
var cl = require('cl')
|
|
10
|
-
|
|
11
|
-
var opts = nom.script('rock')
|
|
12
|
-
.option('version', {help: 'Print version and exit.', flag: true, callback: function() { return require('../package.json').version }})
|
|
13
|
-
.option('path', {help: 'Output path of generated directory structure.', position: 0, required: true})
|
|
14
|
-
.option('rock', {help: 'The rock path or Github repo.', abbr: 'r', metavar: 'ROCK', required: true})
|
|
15
|
-
.option('config', {help: 'The config file. Defaults to ~/.rock/rock.conf.json', abbr: 'c', default: path.join(osenv.home(), '.rock', 'rock.conf.json')})
|
|
16
|
-
.option('file', {help: 'If the rock is a single file. Supports http as well.', abbr: 'f', flag: true, default: false} )
|
|
17
|
-
.option('topen', {help: 'Opening template value. Defaults to {{', default: '{{'})
|
|
18
|
-
.option('tclose', {help: 'Closing template value. Defaults to }}', default: '}}'})
|
|
19
|
-
.parse()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var config = {}
|
|
23
|
-
if (fs.existsSync(opts.config)) {
|
|
24
|
-
config = fs.readJSONSync(opts.config)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (opts.rock && !opts.file) {
|
|
28
|
-
rock.fetchRepo(opts.path, opts.rock, config)
|
|
29
|
-
.catch(function(err){
|
|
30
|
-
if (err) cl.exit(1, err)
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (opts.rock && opts.file) {
|
|
35
|
-
if (opts.topen && opts.tclose) {
|
|
36
|
-
config.tokens = {open: opts.topen, close: opts.tclose}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
rock.fetchFile(opts.path, opts.rock, config)
|
|
40
|
-
.catch(function(err) {
|
|
41
|
-
if (err) cl.exit(1, err)
|
|
42
|
-
})
|
|
43
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Predefined tokens
|
|
2
|
-
|
|
3
|
-
This is the full list of predefined tokens you can use in your rocks. All tokens begin with `-` to avoid collisions.
|
|
4
|
-
|
|
5
|
-
## File Related
|
|
6
|
-
|
|
7
|
-
- `-file` - The current filename
|
|
8
|
-
|
|
9
|
-
## Date Related
|
|
10
|
-
|
|
11
|
-
Assuming the current date was September 7, 2016; and the time was around 1:05 PM:
|
|
12
|
-
|
|
13
|
-
| Token | Value |
|
|
14
|
-
| --- | --- |
|
|
15
|
-
| `-date-year` | 2016 |
|
|
16
|
-
| `-date-month` | 09 |
|
|
17
|
-
| `-date-day` | 07 |
|
|
18
|
-
| `-date-hour` | 13 |
|
|
19
|
-
| `-date-hours` | 13 |
|
|
20
|
-
| `-date-minute` | 05 |
|
|
21
|
-
| `-date-minutes` | 05 |
|
|
22
|
-
| `-date-mins` | 05 |
|
|
23
|
-
| `-date-secs` | 33 |
|
|
24
|
-
| `-date-seconds` | 33 |
|
|
25
|
-
| `-date-millis` | 345 |
|
|
26
|
-
| `-date-milliseconds` | 345 |
|
|
27
|
-
| `-date-ymd` | 2016-09-07 |
|
|
28
|
-
| `-date-hms` | 13-05-33 |
|
|
29
|
-
| `-date-ymd` | 2016-09-07-13-05-33 |
|
|
30
|
-
| `-date-ymd_hms` | 2016-09-07_13-05-33 |
|
|
31
|
-
| `-date-iso` | 2016-09-07T18:05:33.345Z |
|
package/lib/rock.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
var fs = require('fs-promise')
|
|
2
|
-
var path = require('path')
|
|
3
|
-
var walker = require('walker')
|
|
4
|
-
var tweezers = require('./tweezers')
|
|
5
|
-
var dt = require('date-tokens')
|
|
6
|
-
var rlp = require('readline-prompter')
|
|
7
|
-
var ghdownload = require('github-download')
|
|
8
|
-
var rutil = require('./util')
|
|
9
|
-
var S = require('string')
|
|
10
|
-
var agent = require('superagent')
|
|
11
|
-
var globby = require('globby')
|
|
12
|
-
var exists = require('path-exists')
|
|
13
|
-
|
|
14
|
-
S.TMPL_OPEN = '{{'
|
|
15
|
-
S.TMPL_CLOSE = '}}'
|
|
16
|
-
|
|
17
|
-
function fetchFile (filePath, rock, options) {
|
|
18
|
-
if (!options) options = {}
|
|
19
|
-
if (!options.defaultValues) options.defaultValues = {}
|
|
20
|
-
if (!options.templateValues) options.templateValues = {}
|
|
21
|
-
|
|
22
|
-
filePath = path.resolve(filePath)
|
|
23
|
-
|
|
24
|
-
var topen = S.TMPL_OPEN
|
|
25
|
-
var tclose = S.TMPL_CLOSE
|
|
26
|
-
|
|
27
|
-
if (options.tokens) {
|
|
28
|
-
topen = options.tokens.open || S.TMPL_OPEN
|
|
29
|
-
tclose = options.tokens.close || S.TMPL_CLOSE
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Check if rock is local:
|
|
33
|
-
return exists(rock)
|
|
34
|
-
.then(function copyOrDownload (itsLocal) {
|
|
35
|
-
if (itsLocal) { // bug here if dir doesn't exist, TODO: fix
|
|
36
|
-
return fs.copy(rock, filePath)
|
|
37
|
-
} else {
|
|
38
|
-
return new Promise(function (resolve) {
|
|
39
|
-
agent.get(rock).buffer().end(function (res) {
|
|
40
|
-
resolve(fs.outputFile(filePath, res.text))
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
.then(function tweezeFiles () {
|
|
46
|
-
var files = [filePath]
|
|
47
|
-
return tweezers.readFilesAndExtract(files, topen, tclose)
|
|
48
|
-
})
|
|
49
|
-
.then(function promptUser (tokenObj) {
|
|
50
|
-
var replacements = {
|
|
51
|
-
'-file': topen + '-file' + tclose,
|
|
52
|
-
'-literal': topen
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
replacements = rutil.extend(replacements, dt.eval('-date-'))
|
|
56
|
-
replacements = rutil.extend(replacements, options.templateValues)
|
|
57
|
-
|
|
58
|
-
return new Promise(function (resolve) {
|
|
59
|
-
rlp(tokenObj.tokens, options.defaultValues, replacements).end(function (results) {
|
|
60
|
-
resolve(results)
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
.then(function outputFiles (replacements) {
|
|
65
|
-
return fs.readFile(filePath, 'utf8')
|
|
66
|
-
.then(function (data) {
|
|
67
|
-
replacements['-file'] = path.basename(filePath)
|
|
68
|
-
var newFileData = S(data).template(replacements, topen, tclose).s
|
|
69
|
-
return fs.writeFile(filePath, newFileData)
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function fetchRepo (projectPath, repoPath, options) {
|
|
75
|
-
projectPath = path.resolve(projectPath)
|
|
76
|
-
var projectRockPath = path.join(projectPath, '.rock')
|
|
77
|
-
var projectRockConf = path.join(projectRockPath, 'rock.json')
|
|
78
|
-
var projectRockObj = {} // empty config
|
|
79
|
-
|
|
80
|
-
if (!options) options = {}
|
|
81
|
-
if (!options.defaultValues) options.defaultValues = {}
|
|
82
|
-
if (!options.templateValues) options.templateValues = {}
|
|
83
|
-
|
|
84
|
-
// Check if rock is local:
|
|
85
|
-
return exists(repoPath)
|
|
86
|
-
.then(function copyOrDownload (itsLocal) {
|
|
87
|
-
if (itsLocal) {
|
|
88
|
-
return fs.copy(repoPath, projectPath, {filter: function (p) {
|
|
89
|
-
return !/.*\/\.git$/.test(p)
|
|
90
|
-
}})
|
|
91
|
-
} else {
|
|
92
|
-
return new Promise(function (resolve, reject) {
|
|
93
|
-
ghdownload(repoPath, projectPath)
|
|
94
|
-
.on('error', reject)
|
|
95
|
-
.on('end', resolve)
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
.then(function checkRockConf () {
|
|
100
|
-
return exists(projectRockConf)
|
|
101
|
-
})
|
|
102
|
-
.then(function loadRockConf (rockConfExists) {
|
|
103
|
-
if (rockConfExists) {
|
|
104
|
-
return fs.readJson(projectRockConf)
|
|
105
|
-
.then(function (data) {
|
|
106
|
-
if (data) {
|
|
107
|
-
projectRockObj = data
|
|
108
|
-
|
|
109
|
-
if (projectRockObj.tokens) {
|
|
110
|
-
S.TMPL_OPEN = projectRockObj.tokens.open || S.TMPL_OPEN
|
|
111
|
-
S.TMPL_CLOSE = projectRockObj.tokens.close || S.TMPL_CLOSE
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
})
|
|
117
|
-
.then(function walkFilesAndLoadTokenSettings (data) {
|
|
118
|
-
// console.log('walkFiles')
|
|
119
|
-
var files = []
|
|
120
|
-
var ignoreDirs = []
|
|
121
|
-
|
|
122
|
-
if (projectRockObj) {
|
|
123
|
-
ignoreDirs = projectRockObj.ignoreDirs || []
|
|
124
|
-
ignoreDirs = ignoreDirs.map(function (dir) {
|
|
125
|
-
return path.resolve(projectPath, dir)
|
|
126
|
-
})
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return new Promise(function (resolve, reject) {
|
|
130
|
-
walker(projectPath)
|
|
131
|
-
.filterDir(function (dir, stat) { // return false if you want to filter
|
|
132
|
-
// if current dir is the .rock filter, then obviously filter... else filter if it is found in ignoreDirs
|
|
133
|
-
return (dir === projectRockPath) ? false : !(ignoreDirs.indexOf(dir) >= 0)
|
|
134
|
-
})
|
|
135
|
-
.on('file', function (file) { files.push(file) })
|
|
136
|
-
.on('error', reject)
|
|
137
|
-
.on('end', function () {
|
|
138
|
-
resolve(files)
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
.then(function tweezeFiles (files) {
|
|
143
|
-
// console.log('tweezefiles')
|
|
144
|
-
return tweezers.readFilesAndExtract(files, S.TMPL_OPEN, S.TMPL_CLOSE)
|
|
145
|
-
})
|
|
146
|
-
.then(function promptUser (tokenObj) {
|
|
147
|
-
var replacements = {
|
|
148
|
-
'-file': S.TMPL_OPEN + '-file' + S.TMPL_CLOSE,
|
|
149
|
-
'-literal': S.TMPL_OPEN
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
replacements = rutil.extend(replacements, dt.eval('-date-'))
|
|
153
|
-
replacements = rutil.extend(replacements, options.templateValues)
|
|
154
|
-
|
|
155
|
-
return new Promise(function (resolve) {
|
|
156
|
-
rlp(tokenObj.tokens, options.defaultValues, replacements).end(function (results) {
|
|
157
|
-
resolve({
|
|
158
|
-
tokenObj: tokenObj,
|
|
159
|
-
replacements: results
|
|
160
|
-
})
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
})
|
|
164
|
-
.then(function outputFiles (results) {
|
|
165
|
-
var tokenObj = results.tokenObj
|
|
166
|
-
var replacements = results.replacements
|
|
167
|
-
delete tokenObj.tokens // we just want to process the files
|
|
168
|
-
|
|
169
|
-
// For each file:
|
|
170
|
-
return Promise.all(Object.keys(tokenObj).map(function (file) {
|
|
171
|
-
// Read it:
|
|
172
|
-
return fs.readFile(file, 'utf8')
|
|
173
|
-
.then(function renderTemplate (data) {
|
|
174
|
-
var newFileName = S(file).template(replacements).s
|
|
175
|
-
replacements['-file'] = path.basename(newFileName)
|
|
176
|
-
|
|
177
|
-
var newFileData = S(data).template(replacements).s
|
|
178
|
-
|
|
179
|
-
return fs.writeFile(newFileName, newFileData)
|
|
180
|
-
.then(function () {
|
|
181
|
-
// Pass newFileName to next function:
|
|
182
|
-
return newFileName
|
|
183
|
-
})
|
|
184
|
-
})
|
|
185
|
-
.then(function deleteOldFile (newFileName) {
|
|
186
|
-
if (file !== newFileName) {
|
|
187
|
-
return fs.remove(file)
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
})) // End of Promise.all
|
|
191
|
-
})
|
|
192
|
-
.then(function getDeleteFolderList () {
|
|
193
|
-
var deleteArr = []
|
|
194
|
-
if (projectRockObj.delete) {
|
|
195
|
-
deleteArr = globby.sync(projectRockObj.delete, {cwd: projectPath})
|
|
196
|
-
// Convert to absolute paths:
|
|
197
|
-
deleteArr = deleteArr.map(function (dir) {
|
|
198
|
-
return path.join(projectPath, dir)
|
|
199
|
-
})
|
|
200
|
-
}
|
|
201
|
-
// Add .rock to delete array:
|
|
202
|
-
deleteArr.push(projectRockPath)
|
|
203
|
-
return deleteArr
|
|
204
|
-
})
|
|
205
|
-
.then(function deleteFolders (deleteArr) {
|
|
206
|
-
return Promise.all(deleteArr.map(function (dir) {
|
|
207
|
-
return fs.remove(dir)
|
|
208
|
-
}))
|
|
209
|
-
})
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
module.exports.fetchRepo = fetchRepo
|
|
213
|
-
module.exports.fetchFile = fetchFile
|
package/lib/tweezers.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var fs = require('fs-promise')
|
|
2
|
-
var tweeze = require('tweezers')
|
|
3
|
-
var rutil = require('./util')
|
|
4
|
-
|
|
5
|
-
var me = module.exports
|
|
6
|
-
me.open = null
|
|
7
|
-
me.close = null
|
|
8
|
-
|
|
9
|
-
function readFileAndExtract (file, callback) {
|
|
10
|
-
return fs.readFile(file, 'utf8')
|
|
11
|
-
.then(function (data) {
|
|
12
|
-
return tweeze(data, me.open, me.close)
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function readFilesAndExtract (files, open, close) {
|
|
17
|
-
var fileObj = {}
|
|
18
|
-
var tokens = {}
|
|
19
|
-
|
|
20
|
-
me.open = open || me.open
|
|
21
|
-
me.close = close || me.open
|
|
22
|
-
|
|
23
|
-
return Promise.all(files.map(function (file) {
|
|
24
|
-
return readFileAndExtract(file)
|
|
25
|
-
.then(function (obj) {
|
|
26
|
-
rutil.extend(tokens, obj)
|
|
27
|
-
fileObj[file] = Object.keys(obj)
|
|
28
|
-
})
|
|
29
|
-
}))
|
|
30
|
-
.then(function () {
|
|
31
|
-
fileObj.tokens = Object.keys(tokens)
|
|
32
|
-
fileObj.tokens.sort()
|
|
33
|
-
return fileObj
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports.readFilesAndExtract = readFilesAndExtract
|
package/lib/util.js
DELETED
package/test/mocha.opts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
(The MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) JP Richardson
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
|
6
|
-
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
|
7
|
-
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
13
|
-
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
|
14
|
-
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
15
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This should not have {{author}} populated.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{-date-ymd}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@@-literal@@
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{{-literal}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('ROCK SCRIPT: bye');
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
(The MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) {{author}}
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
|
6
|
-
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
|
7
|
-
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
13
|
-
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
|
14
|
-
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
15
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
This should not have {{author}} populated.
|