Permalink
Browse files

Upgrade seed to use tiki. Drop dependency on node.

  • Loading branch information...
1 parent fe0c0ab commit 0bb77bee5d9d7b70987b415882937426ebd853a3 Charles Jolley committed Apr 6, 2010
Showing with 4,557 additions and 6,330 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 bin/seed
  3. +2 −1 bin/seed-repl
  4. +7 −0 docs/PLATFORMS.rd
  5. +1 −0 fixtures/basic/lib/doubles/fig.coffee
  6. +1 −0 fixtures/basic/lib/doubles/fig.js
  7. +1 −0 fixtures/basic/lib/fig.coffee
  8. +3 −1 fixtures/basic/package.json
  9. +1 −0 fixtures/basic/tests/a_test.js
  10. +0 −8 fixtures/loaders/package.json
  11. 0 fixtures/{demo_repository → test-source}/config.json
  12. 0 fixtures/{demo_repository/packages/bar-3.2.1 → test-source/packages/bar/3.2.1}/lib/index.js
  13. +1 −0 fixtures/{demo_repository/packages/bar-3.2.1 → test-source/packages/bar/3.2.1}/package.json
  14. 0 fixtures/{demo_repository/packages/foo-1.2.1 → test-source/packages/foo/1.2.1}/lib/index.js
  15. 0 fixtures/{demo_repository/packages/foo-1.2.1 → test-source/packages/foo/1.2.1}/package.json
  16. 0 fixtures/{demo_repository/packages/foo-2.0.0 → test-source/packages/foo/2.0.0}/lib/index.js
  17. 0 fixtures/{demo_repository/packages/foo-2.0.0 → test-source/packages/foo/2.0.0}/package.json
  18. +3 −0 fixtures/with_local/local.json
  19. +4 −0 fixtures/with_local/package.json
  20. +22 −5 index.js
  21. +36 −36 lib/commands.js
  22. +10 −10 lib/commands/config.js
  23. +54 −74 lib/commands/fork.js
  24. +38 −46 lib/commands/freeze.js
  25. +9 −8 lib/commands/help.js
  26. +45 −36 lib/commands/install.js
  27. +60 −55 lib/commands/list.js
  28. +11 −12 lib/commands/push.js
  29. +52 −41 lib/commands/remote.js
  30. +39 −41 lib/commands/remove.js
  31. +35 −34 lib/commands/unfreeze.js
  32. +3 −3 lib/commands/update.js
  33. +0 −229 lib/config.js
  34. +32 −55 lib/index.js
  35. +329 −0 lib/jspragma.js
  36. +0 −434 lib/loader.js
  37. +50 −0 lib/native-reader.js
  38. +446 −738 lib/package.js
  39. +0 −982 lib/private/co.js
  40. +277 −0 lib/private/core.js
  41. +439 −0 lib/private/fs.js
  42. +518 −0 lib/private/iter.js
  43. +0 −16 lib/private/loop.js
  44. +30 −0 lib/private/path.js
  45. +114 −0 lib/private/platform.js
  46. +0 −63 lib/private/string_scanner.js
  47. +218 −0 lib/reader.js
  48. +224 −261 lib/remote.js
  49. +0 −469 lib/repository.js
  50. +0 −346 lib/resource.js
  51. +0 −289 lib/sandbox.js
  52. +154 −807 lib/seed.js
  53. +0 −316 lib/semver.js
  54. +392 −0 lib/source.js
  55. +129 −0 lib/special-packages.js
  56. +2 −7 package.json
  57. +0 −36 tests/co/path.js
  58. +0 −38 tests/commands/collectPluginInfo.js
  59. +0 −26 tests/common.js
  60. +39 −0 tests/helpers.js
  61. +24 −0 tests/integration_test.js
  62. +17 −14 tests/{loader/pragmas.js → jspragma_test.js}
  63. +0 −63 tests/loop.js
  64. +35 −0 tests/package/canonicalPackageId_test.js
  65. +107 −0 tests/package/config_test.js
  66. +60 −0 tests/package/exists_test.js
  67. +0 −20 tests/package/info.js
  68. +68 −0 tests/package/load_test.js
  69. +92 −0 tests/package/normalize_test.js
  70. +0 −31 tests/package/open.js
  71. +0 −23 tests/package/openGlobalConfig.js
  72. +35 −0 tests/package/packageFor_test.js
  73. +0 −73 tests/package/setup_teardown.js
  74. +0 −38 tests/repository/compatiblePackage.js
  75. +0 −30 tests/repository/open.js
  76. +0 −194 tests/resource.js
  77. +0 −60 tests/seed/canonical.js
  78. +0 −36 tests/seed/collectMergedPluginInfo.js
  79. +0 −78 tests/seed/packageList.js
  80. +0 −82 tests/seed/require.js
  81. +30 −0 tests/seed/setup_test.js
  82. +0 −64 tests/semver.js
  83. +49 −0 tests/source/canonicalPackageId_test.js
  84. +63 −0 tests/source/config_test.js
  85. +54 −0 tests/source/packageFor_test.js
  86. +37 −0 tests/special_packages/AnonymousPackage_test.js
  87. +53 −0 tests/special_packages/DefaultPackage_test.js
View
@@ -1,3 +1,4 @@
tmp
build
.lock-wscript
+old
View
@@ -5,4 +5,4 @@ var commands = seed.require('seed:commands');
// first two args are 'node' and path to this binary
var args = Array.prototype.slice.call(process.argv, 2);
-commands.invokeSync(args.shift(), args);
+commands.invokeSync(args.shift(), args);
View
@@ -5,4 +5,5 @@
var repl = require('default:repl');
repl.start('seed> ');
-repl.scope.seed = require.seed;
+repl.scope.require = require;
+repl.scope.module = module;
View
@@ -0,0 +1,7 @@
+# Porting Seed to New JS Platforms
+
+Seed is intended to run on many different JavaScript platforms. To add
+support for your specific JavaScript platform, you just need to make sure the
+methods in the lib/platform.js file works as expected. See that files for
+more information.
+
@@ -0,0 +1 @@
+// ANOTHER FIG!
@@ -0,0 +1 @@
+// JS Fig
@@ -0,0 +1 @@
+// ARG! CoffeeScript ahoy
@@ -1,5 +1,7 @@
{
"name": "basic",
"version": "0.1.0",
- "description": "basic example project"
+ "description": "basic example project",
+
+ "seed:pass-through": "not modified"
}
@@ -0,0 +1 @@
+// used to lookup modules
@@ -1,8 +0,0 @@
-{
- "name": "loaders",
- "description": "for testing alternate loaders",
-
- "seed:loader": {
- ".coffeescript": "coffeescript"
- }
-}
@@ -1,5 +1,6 @@
{
"name": "bar",
+ "version": "3.2.1",
"dependencies": {
"foo": "1.1"
}
@@ -0,0 +1,3 @@
+{
+ "testProperty": "local"
+}
@@ -0,0 +1,4 @@
+{
+ "name": "with_local",
+ "testProperty": "package"
+}
View
@@ -7,10 +7,27 @@
/**
@file
- Bootstraps the seed package manager for node. Place the seed directory
- into your .node_libraries folder. When you require('seed') you will get
- this file back [which really just forwards to the package index].
-
+ Bootstraps the seed package manager. This should be the first module you
+ actually load directly from the engine to get a seed environment going.
+
+ This assume you have a very primitive require() method that can at least
+ load modules relatives to this one.
*/
-exports = module.exports = require('./lib/index');
+var Seed = require('./lib/seed').Seed,
+ core = require('./lib/private/core'),
+ seed, configPath, SEED_ENV;
+
+
+// find the seed config file. It's at ~/.seeds/config.json
+configPath = core.env.SEED_CONFIG || '~/.seeds/config.json';
+configPath = core.path.normalize(configPath);
+
+// create a default seed instance. This is usually what people will work
+// with.
+seed = module.exports = new Seed(configPath, core.env, core.args);
+seed.addDefaultSources();
+
+// if SEED_ENV is defined shift that in as well
+SEED_ENV = core.env.SEED_ENV;
+if (SEED_ENV) seed.register(core.path.normalize(SEED_ENV));
View
@@ -3,14 +3,12 @@
// Copyright: ©2009-2010 Apple Inc. All rights reserved.
// License: Licened under MIT license (see __preamble__.js)
// ==========================================================================
-/*globals process */
-if (!require.seed) throw "Can only load from within seed";
+if (!require.sandbox) throw new Error("Can only load from within seed");
-var Co = require('private/co');
+var core = require('private/core');
var optparse = require('private/optparse');
var Cmds = exports;
-var seed = require.seed;
var help = require('commands/help');
var STD_SWITCHES = [
@@ -27,7 +25,7 @@ exports.STD_SWITCHES = STD_SWITCHES;
function preferredSource() {
// choose a repository to go to. last source not a package.
var repo,
- sources = seed.sources;
+ sources = require.sandbox.loader.sources;
for(var loc=0;(loc<sources.length) && !repo; loc++) {
if (sources[loc].acceptsInstalls) repo = sources[loc];
}
@@ -40,46 +38,47 @@ exports.preferredSource = preferredSource;
//
// log some output but only if we are in verbose mode
-Cmds.verbose = Co.verbose;
+Cmds.verbose = core.verbose;
// logs strings as a failed command and then exits done
-Cmds.fail = Co.fail;
+Cmds.fail = core.fail;
/**
Invokes callback with hash of plugin information
*/
-Cmds.collectPluginInfo = function(done) {
- var pkg = module.pkg || seed.seedPackage;
- require.seed.collectPluginInfo(pkg, 'seed:commands', done);
+Cmds.collectPluginInfo = function(key, packages) {
+ var ret = {};
+ if (!packages) packages = require.catalogPackages();
+ packages.forEach(function(pkg) {
+ var info = pkg.get(key);
+ if (info) ret[pkg.id] = info;
+ });
+
+ return ret ;
};
/**
Invokes callback with hash of commands mapped to property paths
*/
-Cmds.commands = Co.once(function(done) {
- var pkg = module.pkg || seed.seedPackage,
- SEED = require.seed;
-
- Cmds.collectPluginInfo(function(err, pluginInfo) {
- if (err) return done(err);
+Cmds.commands = core.once(function(done) {
+ var pluginInfo = Cmds.collectPluginInfo('seed:commands');
- var ret = Co.mixin({}, pluginInfo['seed']);
- Object.keys(pluginInfo).forEach(function(packageId) {
- if (packageId === 'seed') return ; // skip since we put it there first
-
- var commands = pluginInfo[packageId];
- if (!commands) return ; // nothing to do
-
- for(var key in commands) {
- if (!commands.hasOwnProperty(key)) continue;
- var path = commands[key];
- if (path.indexOf(':')<0) path = packageId + ':' + path; // namespace
- ret[key.toLowerCase()] = path;
- }
- });
+ var ret = core.mixin({}, pluginInfo['seed']);
+ Object.keys(pluginInfo).forEach(function(packageId) {
+ if (packageId === 'seed') return ; // skip since we put it there first
+
+ var commands = pluginInfo[packageId];
+ if (!commands) return ; // nothing to do
- done(null, ret);
+ for(var key in commands) {
+ if (!commands.hasOwnProperty(key)) continue;
+ var path = commands[key];
+ if (path.indexOf(':')<0) path = packageId + ':' + path; // namespace
+ ret[key.toLowerCase()] = path;
+ }
});
+
+ return done(null, ret);
});
@@ -88,10 +87,11 @@ Cmds.commands = Co.once(function(done) {
on the system.
*/
Cmds.invoke = function(cmd, args, done) {
- if (arguments.length<2) throw "invoke() requires least cmd and callback";
+ if (arguments.length<2) throw new Error("invoke() requires least cmd and callback");
if (!cmd) cmd = 'help';
+
Cmds.commands(function(err, commands) {
if (err) return done(err);
var packageId = commands[cmd.toLowerCase()], exports;
@@ -111,7 +111,7 @@ Cmds.invoke = function(cmd, args, done) {
// ok try to parse the options and see if we need to do help
var showHelp = false;
opts.on('help', function() { showHelp = true; });
- opts.on('verbose', function() { process.env.VERBOSE = true; });
+ opts.on('verbose', function() { require.env.VERBOSE = true; });
opts.parse(args);
if (showHelp) {
return help.invoke(cmd, [cmd], opts, done);
@@ -126,9 +126,9 @@ Cmds.invoke = function(cmd, args, done) {
};
Cmds.invokeSync = function(cmd, args) {
- return Co.wait(function(done) {
+ return core.wait(function(done) {
Cmds.invoke(cmd, args, function(err) {
- if (err) Co.println(err);
+ if (err) core.println(err);
return done();
});
});
@@ -138,6 +138,6 @@ Cmds.invokeSync = function(cmd, args) {
Invoked whenever you call an unknown command
*/
Cmds.unknown = function(name, args, opts, done) {
- Co.println("Command Unknown: " + name);
+ core.println("Command Unknown: " + name);
help.invoke(null, [], opts, done);
};
View
@@ -4,9 +4,9 @@
// License: Licened under MIT license (see __preamble__.js)
// ==========================================================================
-if (!require.seed) throw "Can only load from within seed";
+if (!require.sandbox) throw "Can only load from within seed";
-var Co = require('private/co');
+var core = require('private/core');
var seed = require.seed;
var semver = require('semver');
@@ -27,7 +27,7 @@ function showAllConfigs(sources, done) {
if (base) key = base + '.' + key;
if (key === 'seed.commands') continue;
if (('object' === typeof val) && !Array.isArray(val)) iter(val, key);
- else if (val !== undefined) configs[key] = Co.inspect(val);
+ else if (val !== undefined) configs[key] = core.inspect(val);
}
}
@@ -38,7 +38,7 @@ function showAllConfigs(sources, done) {
for(var key in configs) {
if (!configs.hasOwnProperty(key)) continue;
- Co.println(key + ': ' + configs[key]);
+ core.println(key + ': ' + configs[key]);
}
done();
@@ -78,12 +78,12 @@ function writeableConfig(source, path) {
key = ret.key = path.shift();
working = source.info(key);
- working = isHash(working) ? Co.mixin({}, working) : {};
+ working = isHash(working) ? core.mixin({}, working) : {};
ret.root = working;
while(key = path.shift()) {
next = working[key];
- next = isHash(next) ? Co.mixin({}, next) : {};
+ next = isHash(next) ? core.mixin({}, next) : {};
working[key] = next;
working = next;
}
@@ -123,13 +123,13 @@ exports.invoke = function(cmd, args, opts, done) {
src = sources[loc];
ret = src.info(key);
}
- Co.println(key + ': '+Co.inspect(ret));
+ core.println(key + ': '+core.inspect(ret));
}
done();
// replace config
} else {
- Co.debug(Co.inspect(sources.map(function(src) { return src.config.path; })));
+ core.debug(core.inspect(sources.map(function(src) { return src.config.path; })));
src = sources[sources.length-1];
if (key.indexOf('.')>=0) {
@@ -140,8 +140,8 @@ exports.invoke = function(cmd, args, opts, done) {
} else {
src.info(key, makeNative(value));
- Co.println(key + ': '+Co.inspect(src.info(key)));
- Co.debug(src.config.path);
+ core.println(key + ': '+core.inspect(src.info(key)));
+ core.debug(src.config.path);
src.write(function(err) { return done(err); });
}
}
Oops, something went wrong.

0 comments on commit 0bb77be

Please sign in to comment.