sproutit-narwhal 0.1.106
Sign up to get free protection for your applications and to get access to all the features.
- data/DISTRIBUTION.yml +15 -0
- data/README.md +86 -0
- data/Rakefile +349 -0
- data/VERSION.yml +7 -0
- data/bin/activate +50 -0
- data/bin/activate.bash +50 -0
- data/bin/activate.cmd +3 -0
- data/bin/js +67 -0
- data/bin/json +2 -0
- data/bin/narwhal +67 -0
- data/bin/narwhal.cmd +29 -0
- data/bin/sea +45 -0
- data/bin/sea.cmd +25 -0
- data/bin/tusk +2 -0
- data/bin/tusk.cmd +5 -0
- data/catalog.json +902 -0
- data/docs/available-packages.md +32 -0
- data/docs/browser-api-plan.md +290 -0
- data/docs/browser-api.md +153 -0
- data/docs/download.md +25 -0
- data/docs/engines.md +32 -0
- data/docs/json-tool.md +121 -0
- data/docs/lib/binary.wiki +242 -0
- data/docs/lib/file.wiki +325 -0
- data/docs/lib/os/popen.md +70 -0
- data/docs/modules.md +38 -0
- data/docs/narwhal.md +487 -0
- data/docs/packages-howto.md +32 -0
- data/docs/packages.md +30 -0
- data/docs/posts/2009-07-29-hello-0.1.md +19 -0
- data/docs/quick-start.md +69 -0
- data/docs/sea.md +49 -0
- data/engines/browser/lib/binary.js +2 -0
- data/engines/browser/lib/reactor.js +21 -0
- data/engines/browser/lib/system.js +3 -0
- data/engines/default/lib/array.js +164 -0
- data/engines/default/lib/binary-engine.js +53 -0
- data/engines/default/lib/binary.js +755 -0
- data/engines/default/lib/date.js +8 -0
- data/engines/default/lib/file-engine.js +119 -0
- data/engines/default/lib/function.js +119 -0
- data/engines/default/lib/global.js +11 -0
- data/engines/default/lib/io-engine.js +26 -0
- data/engines/default/lib/json.js +488 -0
- data/engines/default/lib/object.js +69 -0
- data/engines/default/lib/os-engine.js +3 -0
- data/engines/default/lib/reactor.js +12 -0
- data/engines/default/lib/string.js +84 -0
- data/engines/default/lib/system.js +20 -0
- data/engines/default/lib/worker.js +133 -0
- data/engines/jsc/README.md +18 -0
- data/engines/jsc/bootstrap.js +53 -0
- data/engines/jsc/deps/http-parser/LICENSE +77 -0
- data/engines/jsc/deps/http-parser/README.md +145 -0
- data/engines/jsc/deps/http-parser/http_parser.c +6087 -0
- data/engines/jsc/deps/http-parser/http_parser.h +141 -0
- data/engines/jsc/deps/http-parser/http_parser.rl +500 -0
- data/engines/jsc/deps/http-parser/test.c +858 -0
- data/engines/jsc/include/binary-engine.h +11 -0
- data/engines/jsc/include/io-engine.h +23 -0
- data/engines/jsc/include/narwhal.h +427 -0
- data/engines/jsc/lib/file-engine.js +31 -0
- data/engines/jsc/lib/http.js +1 -0
- data/engines/jsc/lib/io-engine.js +202 -0
- data/engines/jsc/lib/os-engine.js +25 -0
- data/engines/jsc/lib/system.js +18 -0
- data/engines/jsc/lib/zip.js +1 -0
- data/engines/jsc/narwhal-jsc.c +273 -0
- data/engines/jsc/narwhal.c +29 -0
- data/engines/jsc/package.json +8 -0
- data/engines/jsc/src/binary-engine.cc +290 -0
- data/engines/jsc/src/file-engine.cc +405 -0
- data/engines/jsc/src/io-engine.cc +423 -0
- data/engines/jsc/src/jack/handler/jill.cc +710 -0
- data/engines/jsc/src/os-engine.cc +210 -0
- data/engines/rhino/bin/narwhal-rhino +68 -0
- data/engines/rhino/bin/narwhal-rhino.cmd +34 -0
- data/engines/rhino/bootstrap.js +119 -0
- data/engines/rhino/jars/jline.jar +0 -0
- data/engines/rhino/jars/jna.jar +0 -0
- data/engines/rhino/jars/js.jar +0 -0
- data/engines/rhino/lib/binary-engine.js +83 -0
- data/engines/rhino/lib/concurrency.js +6 -0
- data/engines/rhino/lib/event-queue.js +18 -0
- data/engines/rhino/lib/file-engine.js +216 -0
- data/engines/rhino/lib/http-client-engine.js +90 -0
- data/engines/rhino/lib/http-engine.js +10 -0
- data/engines/rhino/lib/io-engine.js +347 -0
- data/engines/rhino/lib/md5-engine.js +40 -0
- data/engines/rhino/lib/os-engine.js +150 -0
- data/engines/rhino/lib/packages-engine.js +71 -0
- data/engines/rhino/lib/sandbox-engine.js +70 -0
- data/engines/rhino/lib/system.js +38 -0
- data/engines/rhino/lib/worker-engine.js +23 -0
- data/engines/rhino/lib/zip.js +78 -0
- data/engines/rhino/package.json +4 -0
- data/engines/secure/lib/file.js +6 -0
- data/engines/secure/lib/system.js +6 -0
- data/engines/template/bin/narwhal-engine-name +32 -0
- data/engines/template/bootstrap.js +40 -0
- data/engines/template/lib/file-engine.js +118 -0
- data/engines/template/lib/system.js +17 -0
- data/examples/browser-deployment-jackconfig.js +35 -0
- data/examples/fibonacci-worker.js +35 -0
- data/examples/fibonacci.js +19 -0
- data/examples/hello +2 -0
- data/examples/narwhal +3 -0
- data/examples/not-quite-a-quine.js +1 -0
- data/extconf.rb +44 -0
- data/gem_bin/narwhal +5 -0
- data/gem_bin/sea +4 -0
- data/gem_bin/tusk +4 -0
- data/lib/args.js +849 -0
- data/lib/base16.js +16 -0
- data/lib/base64.js +120 -0
- data/lib/codec/base64.js +8 -0
- data/lib/crc32.js +60 -0
- data/lib/file-bootstrap.js +187 -0
- data/lib/file.js +659 -0
- data/lib/hash.js +28 -0
- data/lib/hashp.js +65 -0
- data/lib/html.js +16 -0
- data/lib/http-client.js +134 -0
- data/lib/http.js +17 -0
- data/lib/io.js +98 -0
- data/lib/jsmin.js +315 -0
- data/lib/jsonpath.js +89 -0
- data/lib/logger.js +55 -0
- data/lib/md4.js +146 -0
- data/lib/md5.js +164 -0
- data/lib/mime.js +166 -0
- data/lib/narwhal.js +102 -0
- data/lib/narwhal/client.js +261 -0
- data/lib/narwhal/compile.js +99 -0
- data/lib/narwhal/env.js +140 -0
- data/lib/narwhal/inline.js +106 -0
- data/lib/narwhal/json.js +324 -0
- data/lib/narwhal/json.md +178 -0
- data/lib/narwhal/repl.js +96 -0
- data/lib/narwhal/server-test.js +6 -0
- data/lib/narwhal/server.js +270 -0
- data/lib/narwhal/tusk.js +170 -0
- data/lib/narwhal/tusk/bin.js +13 -0
- data/lib/narwhal/tusk/bundle.js +0 -0
- data/lib/narwhal/tusk/catalog.js +22 -0
- data/lib/narwhal/tusk/clone.js +66 -0
- data/lib/narwhal/tusk/consolidate.js +25 -0
- data/lib/narwhal/tusk/create-catalog.js +80 -0
- data/lib/narwhal/tusk/engine.js +42 -0
- data/lib/narwhal/tusk/freeze.js +0 -0
- data/lib/narwhal/tusk/init.js +56 -0
- data/lib/narwhal/tusk/install.js +288 -0
- data/lib/narwhal/tusk/list.js +20 -0
- data/lib/narwhal/tusk/orphans.js +0 -0
- data/lib/narwhal/tusk/reheat.js +15 -0
- data/lib/narwhal/tusk/remove.js +15 -0
- data/lib/narwhal/tusk/search.js +145 -0
- data/lib/narwhal/tusk/update.js +21 -0
- data/lib/narwhal/tusk/upgrade.js +0 -0
- data/lib/os.js +33 -0
- data/lib/packages.js +423 -0
- data/lib/printf.js +169 -0
- data/lib/promise.js +352 -0
- data/lib/querystring.js +176 -0
- data/lib/ref-send.js +257 -0
- data/lib/regexp.js +12 -0
- data/lib/sandbox.js +422 -0
- data/lib/sha.js +112 -0
- data/lib/sha256.js +102 -0
- data/lib/struct.js +228 -0
- data/lib/term.js +179 -0
- data/lib/test/assert.js +95 -0
- data/lib/test/equiv.js +188 -0
- data/lib/test/jsdump.js +165 -0
- data/lib/test/runner.js +129 -0
- data/lib/unload.js +13 -0
- data/lib/uri.js +378 -0
- data/lib/url.js +5 -0
- data/lib/utf8.js +64 -0
- data/lib/util.js +985 -0
- data/lib/uuid.js +89 -0
- data/lib/xregexp.js +521 -0
- data/local.json.template +1 -0
- data/narwhal.gemspec +105 -0
- data/narwhal.js +213 -0
- data/package.json +26 -0
- data/packages/readline/engines/default/lib/readline.js +4 -0
- data/packages/readline/engines/rhino/lib/readline.js +6 -0
- data/packages/readline/package.json +5 -0
- data/sources.json +207 -0
- data/tests/all-tests.js +17 -0
- data/tests/args.js +31 -0
- data/tests/args/domain.js +215 -0
- data/tests/args/options.js +36 -0
- data/tests/args/shifting.js +92 -0
- data/tests/args/validation.js +31 -0
- data/tests/base64.js +23 -0
- data/tests/commonjs.js +3 -0
- data/tests/commonjs/all-tests.js +12 -0
- data/tests/commonjs/bytearray-encodings-tests.js +69 -0
- data/tests/commonjs/bytearray-tests.js +465 -0
- data/tests/commonjs/bytestring-encodings-tests.js +89 -0
- data/tests/commonjs/bytestring-tests.js +263 -0
- data/tests/commonjs/es5/all-tests.js +3 -0
- data/tests/commonjs/es5/bind.js +29 -0
- data/tests/commonjs/file-tests.js +315 -0
- data/tests/commonjs/file/dirname.js +31 -0
- data/tests/commonjs/file/extension.js +45 -0
- data/tests/commonjs/file/is-absolute.js +11 -0
- data/tests/commonjs/file/iterator.js +101 -0
- data/tests/commonjs/file/normal.js +27 -0
- data/tests/commonjs/file/path.js +17 -0
- data/tests/commonjs/file/relative.js +42 -0
- data/tests/commonjs/file/resolve.js +44 -0
- data/tests/commonjs/module-tests.js +9 -0
- data/tests/commonjs/modules/absolute/b.js +1 -0
- data/tests/commonjs/modules/absolute/program.js +5 -0
- data/tests/commonjs/modules/absolute/submodule/a.js +3 -0
- data/tests/commonjs/modules/absolute/test.js +9 -0
- data/tests/commonjs/modules/all-tests.js +47 -0
- data/tests/commonjs/modules/config.js +11 -0
- data/tests/commonjs/modules/cyclic/a.js +4 -0
- data/tests/commonjs/modules/cyclic/b.js +4 -0
- data/tests/commonjs/modules/cyclic/program.js +10 -0
- data/tests/commonjs/modules/cyclic/test.js +9 -0
- data/tests/commonjs/modules/determinism/program.js +3 -0
- data/tests/commonjs/modules/determinism/submodule/a.js +8 -0
- data/tests/commonjs/modules/determinism/submodule/b.js +2 -0
- data/tests/commonjs/modules/determinism/test.js +9 -0
- data/tests/commonjs/modules/exactExports/a.js +3 -0
- data/tests/commonjs/modules/exactExports/program.js +4 -0
- data/tests/commonjs/modules/exactExports/test.js +9 -0
- data/tests/commonjs/modules/hasOwnProperty/hasOwnProperty.js +0 -0
- data/tests/commonjs/modules/hasOwnProperty/program.js +3 -0
- data/tests/commonjs/modules/hasOwnProperty/test.js +9 -0
- data/tests/commonjs/modules/hasOwnProperty/toString.js +0 -0
- data/tests/commonjs/modules/method/a.js +12 -0
- data/tests/commonjs/modules/method/program.js +8 -0
- data/tests/commonjs/modules/method/test.js +9 -0
- data/tests/commonjs/modules/missing/program.js +8 -0
- data/tests/commonjs/modules/missing/test.js +9 -0
- data/tests/commonjs/modules/monkeys/a.js +1 -0
- data/tests/commonjs/modules/monkeys/program.js +4 -0
- data/tests/commonjs/modules/monkeys/test.js +9 -0
- data/tests/commonjs/modules/nested/a/b/c/d.js +3 -0
- data/tests/commonjs/modules/nested/program.js +3 -0
- data/tests/commonjs/modules/nested/test.js +9 -0
- data/tests/commonjs/modules/relative/program.js +5 -0
- data/tests/commonjs/modules/relative/submodule/a.js +1 -0
- data/tests/commonjs/modules/relative/submodule/b.js +2 -0
- data/tests/commonjs/modules/relative/test.js +9 -0
- data/tests/commonjs/modules/transitive/a.js +1 -0
- data/tests/commonjs/modules/transitive/b.js +1 -0
- data/tests/commonjs/modules/transitive/c.js +3 -0
- data/tests/commonjs/modules/transitive/program.js +3 -0
- data/tests/commonjs/modules/transitive/test.js +9 -0
- data/tests/file/all-tests.js +61 -0
- data/tests/file/fnmatch.js +102 -0
- data/tests/file/glob.js +466 -0
- data/tests/file/match.js +102 -0
- data/tests/global.js +6 -0
- data/tests/global/array.js +19 -0
- data/tests/hashes.js +94 -0
- data/tests/html.js +13 -0
- data/tests/io/stringio.js +21 -0
- data/tests/os/all-tests.js +4 -0
- data/tests/os/popen.js +41 -0
- data/tests/os/system.js +22 -0
- data/tests/printf.js +123 -0
- data/tests/query-string.js +87 -0
- data/tests/sandbox/byte-io.js +20 -0
- data/tests/sandbox/fileName.js +3 -0
- data/tests/sandbox/foo.js +0 -0
- data/tests/sandbox/reload.js +79 -0
- data/tests/string.js +35 -0
- data/tests/uri.js +41 -0
- data/tests/util/all-tests.js +79 -0
- data/tests/util/array.js +207 -0
- data/tests/util/array/is-arguments.js +29 -0
- data/tests/util/array/is-array-like.js +29 -0
- data/tests/util/case.js +9 -0
- data/tests/util/collection.js +104 -0
- data/tests/util/eq.js +57 -0
- data/tests/util/expand.js +45 -0
- data/tests/util/object.js +125 -0
- data/tests/util/operator.js +25 -0
- data/tests/util/range.js +19 -0
- data/tests/util/repr.js +26 -0
- data/tests/util/string.js +34 -0
- data/tests/util/unique.js +12 -0
- metadata +434 -0
@@ -0,0 +1,288 @@
|
|
1
|
+
|
2
|
+
var tusk = require("../tusk");
|
3
|
+
var util = require("util");
|
4
|
+
var args = require("args");
|
5
|
+
var fs = require("file");
|
6
|
+
var json = require("json");
|
7
|
+
var http = require("http");
|
8
|
+
var zip = require("zip");
|
9
|
+
var packages = require("packages");
|
10
|
+
|
11
|
+
var parser = exports.parser = new args.Parser();
|
12
|
+
|
13
|
+
parser.help('downloads and installs a package and its dependencies');
|
14
|
+
|
15
|
+
parser.args('package');
|
16
|
+
|
17
|
+
parser.option('-f', '--force', 'force')
|
18
|
+
.bool()
|
19
|
+
.help('causes packages to be installed in the project packages directory regardless of whether they are installed elsewhere');
|
20
|
+
/*
|
21
|
+
parser.option('-l', '--lean', 'lean')
|
22
|
+
.bool()
|
23
|
+
.help('causes only the essential components of the library to be installed.');
|
24
|
+
|
25
|
+
parser.option('-t', '--test', 'test')
|
26
|
+
.bool()
|
27
|
+
.help('run tests before installing');
|
28
|
+
|
29
|
+
parser.option('-d', '--doc', 'doc')
|
30
|
+
.bool()
|
31
|
+
.help('build documentation');
|
32
|
+
*/
|
33
|
+
|
34
|
+
parser.helpful();
|
35
|
+
|
36
|
+
parser.action(function (options) {
|
37
|
+
exports.install.call(this, options, options.args);
|
38
|
+
});
|
39
|
+
|
40
|
+
exports.install = function (options, names) {
|
41
|
+
|
42
|
+
var localSourcePath = fs.path(fs.cwd());
|
43
|
+
|
44
|
+
if (!tusk.getCatalogPath().isFile()) {
|
45
|
+
if (options.simulate) {
|
46
|
+
this.print("Run 'tusk update' or 'tusk create-catalog' to get a catalog.");
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
tusk.update.call(this, options);
|
50
|
+
}
|
51
|
+
|
52
|
+
var parser = this;
|
53
|
+
var catalog = tusk.readCatalog();
|
54
|
+
|
55
|
+
// download a catalog if the current catalog
|
56
|
+
// does not have a version label.
|
57
|
+
if (!catalog.version) {
|
58
|
+
this.print("Run 'tusk update' or 'tusk create-catalog' to get a catalog.");
|
59
|
+
this.print("Your catalog version is no longer supported.");
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
|
63
|
+
// validate the requested names against those
|
64
|
+
// in the catalog of downloadable packages.
|
65
|
+
var names = names.map(function (name) {
|
66
|
+
var localPath = fs.path(fs.absolute(name).replace(/\/$/, "")); // FIXME: basename/dirname broken with trailing slash
|
67
|
+
var localPackagePath = localPath.join("package.json");
|
68
|
+
if (localPackagePath.isFile()) {
|
69
|
+
var packageData = json.decode(localPackagePath.read({charset: 'utf-8'}));
|
70
|
+
var packageName = packageData.name || String(localPath.basename());
|
71
|
+
|
72
|
+
packageData.location = "file://" + localPath;
|
73
|
+
packageData.type = "directory";
|
74
|
+
|
75
|
+
catalog.packages[packageName] = packageData;
|
76
|
+
return packageName;
|
77
|
+
} else if (util.has(catalog.packages, name)) {
|
78
|
+
// nothing to do.
|
79
|
+
return name;
|
80
|
+
}
|
81
|
+
|
82
|
+
parser.print("ERROR: Package not found: " + util.enquote(name));
|
83
|
+
return null;
|
84
|
+
}).filter(function(name) { return !!name; });
|
85
|
+
|
86
|
+
// load the notes on user-requested and dependency packages
|
87
|
+
// for book keeping.
|
88
|
+
var notes = tusk.readNotes();
|
89
|
+
names.forEach(function (name) {
|
90
|
+
if (!notes[name]) {
|
91
|
+
notes[name] = {};
|
92
|
+
}
|
93
|
+
notes[name].requester = "user";
|
94
|
+
});
|
95
|
+
tusk.writeNotes(notes);
|
96
|
+
|
97
|
+
// note broken dependency chains
|
98
|
+
var errors = [];
|
99
|
+
var dependencies = exports.dependencies(catalog.packages, names, errors);
|
100
|
+
if (errors.length) {
|
101
|
+
print('The following dependencies could not be found in the catalog:');
|
102
|
+
printUl(errors.map(function (ancestry) {
|
103
|
+
return ancestry.join(' <- ');
|
104
|
+
}));
|
105
|
+
print('Please notify the package system maintainers.');
|
106
|
+
this.exit();
|
107
|
+
}
|
108
|
+
|
109
|
+
// notify of packages already installed
|
110
|
+
var already = exports.already(packages.catalog, names);
|
111
|
+
if (already.length) {
|
112
|
+
print('The following packages are already installed:');
|
113
|
+
printUl(already);
|
114
|
+
}
|
115
|
+
|
116
|
+
// note missing packages
|
117
|
+
var missing = exports.missing(packages.catalog, dependencies);
|
118
|
+
|
119
|
+
// add forced packages back in
|
120
|
+
if (options.force) {
|
121
|
+
names.forEach(function(name) {
|
122
|
+
if (!util.has(missing, name))
|
123
|
+
missing.push(name);
|
124
|
+
});
|
125
|
+
}
|
126
|
+
|
127
|
+
if (!missing.length) {
|
128
|
+
print('No new packages to install.');
|
129
|
+
this.exit();
|
130
|
+
}
|
131
|
+
print('The following packages will be downloaded and installed:');
|
132
|
+
printUl(missing);
|
133
|
+
|
134
|
+
// download missing packages
|
135
|
+
var zipsDirectory = tusk.getZipsDirectory();
|
136
|
+
zipsDirectory.mkdirs();
|
137
|
+
|
138
|
+
missing.forEach(function (name) {
|
139
|
+
if (/^file:\/\//.test(catalog.packages[name].location)) {
|
140
|
+
print('Local package: ' + name);
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
var info = catalog.packages[name];
|
144
|
+
print('Downloading: ' + info.location);
|
145
|
+
if (options.simulate)
|
146
|
+
return;
|
147
|
+
var zipFile = zipsDirectory.join(name + '.zip')
|
148
|
+
if (options.resume && zipFile.isFile())
|
149
|
+
return;
|
150
|
+
var targetPath = tusk.getDirectory().join('packages', name);
|
151
|
+
var zipData = http.read(info.location, 'b');
|
152
|
+
zipFile.write(zipData, 'b');
|
153
|
+
});
|
154
|
+
|
155
|
+
// install missing packages
|
156
|
+
missing.forEach(function (name) {
|
157
|
+
if (!notes[name])
|
158
|
+
notes[name] = {}
|
159
|
+
if (!notes[name].files)
|
160
|
+
notes[name].files = [];
|
161
|
+
if (!notes[name].requester)
|
162
|
+
notes[name].requester = "module";
|
163
|
+
try {
|
164
|
+
var targetPath = tusk.getDirectory().join('packages', name);
|
165
|
+
if (targetPath.exists()) {
|
166
|
+
if (options.force) {
|
167
|
+
targetPath.rmtree();
|
168
|
+
} else {
|
169
|
+
print("Error: Directory exists: "+targetPath);
|
170
|
+
return;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
var components = catalog.packages[name].location.match(/^file:\/\/(.*)$/);
|
175
|
+
if (components) {
|
176
|
+
var sourcePath = components[1];
|
177
|
+
print('Copying: ' + sourcePath);
|
178
|
+
if (options.simulate)
|
179
|
+
return;
|
180
|
+
|
181
|
+
fs.copyTree(sourcePath, targetPath);
|
182
|
+
|
183
|
+
var files = targetPath.listTree().filter(function(f) { return targetPath.join(f).isFile(); });
|
184
|
+
print(" + " + files.join("\n + "));
|
185
|
+
notes[name].files.push.apply(notes[name].files.push, files);
|
186
|
+
} else {
|
187
|
+
var zipFile = zipsDirectory.join(name + '.zip');
|
188
|
+
print('Unzipping: ' + zipFile);
|
189
|
+
if (options.simulate)
|
190
|
+
return;
|
191
|
+
|
192
|
+
// unzip
|
193
|
+
new zip.Unzip(zipFile).forEach(function (entry) {
|
194
|
+
if (entry.isDirectory())
|
195
|
+
return;
|
196
|
+
var parts = fs.split(entry.getName());
|
197
|
+
parts.shift(); // name-project-comment ref dirname
|
198
|
+
var path = targetPath.join(fs.join.apply(null, parts));
|
199
|
+
path.dirname().mkdirs();
|
200
|
+
notes[name].files.push(path);
|
201
|
+
print(" + " + path);
|
202
|
+
path.write(entry.read('b'), 'b');
|
203
|
+
});
|
204
|
+
}
|
205
|
+
|
206
|
+
// write package.json if it was not in the
|
207
|
+
// archive
|
208
|
+
var packageJson = targetPath.join('package.json');
|
209
|
+
if (!packageJson.isFile())
|
210
|
+
packageJson.write(
|
211
|
+
json.encode(catalog.packages[name], null, 4),
|
212
|
+
{'charset': 'UTF-8'}
|
213
|
+
);
|
214
|
+
|
215
|
+
// make bins executable and make symlinks
|
216
|
+
// in $SEA/bin
|
217
|
+
var bin = targetPath.join('bin');
|
218
|
+
if (bin.isDirectory())
|
219
|
+
bin.list().forEach(function (name) {
|
220
|
+
var target = targetPath.join('bin', name);
|
221
|
+
target.chmod(0755);
|
222
|
+
var sea = tusk.getDirectory().join('bin');
|
223
|
+
var source = sea.join(name);
|
224
|
+
var relative = sea.to(target);
|
225
|
+
if (!source.linkExists()) {
|
226
|
+
target.symlink(source);
|
227
|
+
}
|
228
|
+
});
|
229
|
+
|
230
|
+
notes[name].finished = true;
|
231
|
+
} catch (exception) {
|
232
|
+
var packageJsonPath = tusk.getDirectory().join('packages', name, 'package.json');
|
233
|
+
if (packageJsonPath.isFile())
|
234
|
+
packageJsonPath.remove();
|
235
|
+
throw exception;
|
236
|
+
} finally {
|
237
|
+
tusk.writeNotes(notes);
|
238
|
+
/*
|
239
|
+
if (zipFile.isFile())
|
240
|
+
zipFile.remove();
|
241
|
+
*/
|
242
|
+
}
|
243
|
+
});
|
244
|
+
|
245
|
+
print('Done.');
|
246
|
+
|
247
|
+
};
|
248
|
+
|
249
|
+
function printUl(lines) {
|
250
|
+
lines.forEach(function (line) {
|
251
|
+
print(' * ' + line);
|
252
|
+
});
|
253
|
+
};
|
254
|
+
|
255
|
+
exports.dependencies = function (catalog, names, errors) {
|
256
|
+
var dependencies = {};
|
257
|
+
names.forEach(function (name) {
|
258
|
+
scan(catalog, dependencies, name, [], errors);
|
259
|
+
});
|
260
|
+
return Object.keys(dependencies);
|
261
|
+
};
|
262
|
+
|
263
|
+
var scan = function (catalog, dependencies, name, ancestry, errors) {
|
264
|
+
if (util.has(dependencies, name))
|
265
|
+
return;
|
266
|
+
ancestry = [name].concat(ancestry);
|
267
|
+
if (!util.has(catalog, name)) {
|
268
|
+
errors.push(ancestry);
|
269
|
+
return;
|
270
|
+
}
|
271
|
+
dependencies[name] = true;
|
272
|
+
(catalog[name].dependencies || []).forEach(function (child) {
|
273
|
+
scan(catalog, dependencies, child, ancestry, errors);
|
274
|
+
});
|
275
|
+
};
|
276
|
+
|
277
|
+
exports.already = function (catalog, names) {
|
278
|
+
return names.filter(function (packageName) {
|
279
|
+
return util.has(catalog, packageName);
|
280
|
+
});
|
281
|
+
};
|
282
|
+
|
283
|
+
exports.missing = function (catalog, names) {
|
284
|
+
return names.filter(function (packageName) {
|
285
|
+
return !util.has(catalog, packageName);
|
286
|
+
});
|
287
|
+
};
|
288
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
var tusk = require("../tusk");
|
3
|
+
var util = require("util");
|
4
|
+
var args = require("args");
|
5
|
+
var packages = require("packages");
|
6
|
+
|
7
|
+
var parser = exports.parser = new args.Parser();
|
8
|
+
|
9
|
+
parser.help('lists all installed packages');
|
10
|
+
|
11
|
+
parser.action(function (options) {
|
12
|
+
var self = this;
|
13
|
+
Object.keys(packages.catalog).forEach(function (name) {
|
14
|
+
self.print(
|
15
|
+
name + ' \0magenta(' +
|
16
|
+
packages.catalog[name].directory + '\0)'
|
17
|
+
);
|
18
|
+
});
|
19
|
+
});
|
20
|
+
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
var tusk = require("../tusk");
|
3
|
+
var install = require('./install');
|
4
|
+
var util = require("util");
|
5
|
+
var args = require("args");
|
6
|
+
var packages = require('packages');
|
7
|
+
var parser = exports.parser = new args.Parser();
|
8
|
+
|
9
|
+
parser.help('reconsistutes the exact versions of all dependencies from a frozen project');
|
10
|
+
|
11
|
+
parser.action(function (options, name) {
|
12
|
+
var names = packages.root.dependencies || [];
|
13
|
+
install.install.call(this, options, names);
|
14
|
+
});
|
15
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
var tusk = require("../tusk");
|
3
|
+
var util = require("util");
|
4
|
+
var args = require("args");
|
5
|
+
var parser = exports.parser = new args.Parser();
|
6
|
+
|
7
|
+
parser.help('removes the local copy of package');
|
8
|
+
|
9
|
+
parser.action(function (options) {
|
10
|
+
var names = options.args;
|
11
|
+
});
|
12
|
+
|
13
|
+
exports.remove = function () {
|
14
|
+
};
|
15
|
+
|
@@ -0,0 +1,145 @@
|
|
1
|
+
|
2
|
+
var tusk = require("../tusk");
|
3
|
+
var util = require("util");
|
4
|
+
var http = require("http");
|
5
|
+
var packages = require("packages");
|
6
|
+
var stream = require("term").stream;
|
7
|
+
|
8
|
+
var Parser = exports.Parser = function () {
|
9
|
+
};
|
10
|
+
|
11
|
+
Parser.prototype.act = function (args, options) {
|
12
|
+
this._action(args, options);
|
13
|
+
};
|
14
|
+
|
15
|
+
Parser.prototype._action = function (args, options) {
|
16
|
+
var command = args.shift();
|
17
|
+
var packages = tusk.readCatalog().packages;
|
18
|
+
index(packages);
|
19
|
+
var predicate = Or(args);
|
20
|
+
var results = util.values(packages).map(function (info) {
|
21
|
+
return [predicate(info), info];
|
22
|
+
}).filter(function (pair) {
|
23
|
+
return pair[0] != 0;
|
24
|
+
});
|
25
|
+
util.sort(results);
|
26
|
+
util.forEachApply(results, function (score, info) {
|
27
|
+
stream.print(
|
28
|
+
"\0green(" + info.name + "\0)" +
|
29
|
+
(info.description ? ": " + info.description : "")
|
30
|
+
);
|
31
|
+
});
|
32
|
+
options.acted = true;
|
33
|
+
};
|
34
|
+
|
35
|
+
var index = function (packages) {
|
36
|
+
util.forEachApply(packages, function (name, info) {
|
37
|
+
if (!info.name) {
|
38
|
+
info.name = name;
|
39
|
+
}
|
40
|
+
if (!info.fullText) {
|
41
|
+
info.fullText = [
|
42
|
+
info.name
|
43
|
+
].concat(info.keywords).concat([
|
44
|
+
info.description
|
45
|
+
]).join(" ");
|
46
|
+
}
|
47
|
+
});
|
48
|
+
return packages;
|
49
|
+
}
|
50
|
+
|
51
|
+
var Text = function (args) {
|
52
|
+
args = args.map(function (arg) {
|
53
|
+
return new RegExp(
|
54
|
+
"\\b" + RegExp.escape(arg) + "\\b",
|
55
|
+
"i"
|
56
|
+
);
|
57
|
+
});
|
58
|
+
return function (info) {
|
59
|
+
var accumulator = undefined;
|
60
|
+
return Math.min.apply(this, args.map(function (arg) {
|
61
|
+
return info.fullText.search(arg) + 1;
|
62
|
+
}));
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
var Terms = function (args) {
|
67
|
+
for (var length = 0; length < args.length; length++)
|
68
|
+
if (args[length] == "--")
|
69
|
+
break;
|
70
|
+
if (length) {
|
71
|
+
if (/^--/.test(args[0])) {
|
72
|
+
var pattern = args.shift().match(/^--([^=]+)(?:=(.*))?/).slice(1);
|
73
|
+
var key = pattern[0];
|
74
|
+
var value = pattern[1];
|
75
|
+
if (!!value) {
|
76
|
+
args.unshift(value);
|
77
|
+
}
|
78
|
+
var parts = key.split(".");
|
79
|
+
return function (info) {
|
80
|
+
parts.forEach(function (part) {
|
81
|
+
if (Array.isArray(info)) {
|
82
|
+
info = info.map(function (node) {
|
83
|
+
if (node)
|
84
|
+
return node[part];
|
85
|
+
});
|
86
|
+
} else if (info) {
|
87
|
+
info = info[part];
|
88
|
+
}
|
89
|
+
});
|
90
|
+
var value = args[0];
|
91
|
+
if (Array.isArray(info)) {
|
92
|
+
return util.has(info, value);
|
93
|
+
} else {
|
94
|
+
return info == value;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
} else if (/^-/.test(args[0])) {
|
98
|
+
throw new Error("Option " + args[0] + " not recognized.");
|
99
|
+
} else {
|
100
|
+
return Text(args);
|
101
|
+
}
|
102
|
+
} else {
|
103
|
+
return Text(args);
|
104
|
+
}
|
105
|
+
};
|
106
|
+
|
107
|
+
// - recursive descent scanner
|
108
|
+
// - divide and conquor
|
109
|
+
|
110
|
+
var BinaryOperator = function (Low, High, _, __) {
|
111
|
+
return function Self(args) {
|
112
|
+
var length = args.length;
|
113
|
+
for (var i = 0; i < length; i++)
|
114
|
+
if (args[i] == "--")
|
115
|
+
break;
|
116
|
+
while (i >= 0) {
|
117
|
+
i--;
|
118
|
+
var arg = args[i];
|
119
|
+
if (arg == _ || arg == __) {
|
120
|
+
var left = Self(args.slice(0, i));
|
121
|
+
var right = High(args.slice(i + 1));
|
122
|
+
return function () {
|
123
|
+
return Low(
|
124
|
+
left.apply(this, arguments),
|
125
|
+
right.apply(this, arguments)
|
126
|
+
);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
return High(args);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
var And = BinaryOperator(function (lhs, rhs) {
|
135
|
+
return lhs * rhs;
|
136
|
+
}, Terms, '-a', '--and');
|
137
|
+
|
138
|
+
var Or = BinaryOperator(function (lhs, rhs) {
|
139
|
+
return lhs || rhs ? lhs + rhs : 0;
|
140
|
+
}, And, '-o', '--or');
|
141
|
+
|
142
|
+
Parser.prototype._help = "{keyword}, --and, --or, --{key} {value}";
|
143
|
+
|
144
|
+
exports.parser = new Parser();
|
145
|
+
|