Beispiel #1
0
 return function(err, data) {
     fmt.sep();
     fmt.title(title);
     fmt.dump(err, 'err');
     fmt.dump(data, 'data');
     fmt.sep();
 };
Beispiel #2
0
module.exports = function() {
console.log('\n');
fmt.title('caplin-cli commands');
fmt.field('init', 'Creates a new workspace in the current directory');
fmt.field('create', 'Creates a new file structure based on the selected template');
fmt.field('list', 'Lists the current workspace`s applications and available templates');
fmt.line();
fmt.field('help', 'Prints this list of commands');
fmt.field('version', 'Prints the current caplin-cli version');
console.log('\n');
};
Beispiel #3
0
const startTagRelease = async options => {
	if (options.verbose) {
		fmt.title("GitHub Configuration");
		fmt.field("username", options.username);
		fmt.field("token", options.token);
		fmt.line();
	}

	await setup(options);

	return runWorkflow(options.workflow, options);
};
Beispiel #4
0
module.exports = function createOutputDirs(ctx, callback) {
  fmt.title('Create Output Dirs ...')

  visitEveryDir(
    ctx,
    function(url, dir, done) {
      var dirname = path.join(ctx.cfg.htmlDir, url)
      mkdirp(dirname, done)
    },
    callback
  )
}
        client.pushSnapshot(context.project, context.snapshotPath, {}, function (err) {
            fmt.title(client.remote.toString('long'));
            if (err) {
                console.log(interpolate('could not deploy {project.name}#{project.version} to {remote}', {
                    project: context.project,
                    remote: client.remote
                }));

                return next(err);
            }

            console.log(interpolate('deployed to: {remote}', client));
            next();
        });
Beispiel #6
0
module.exports = function readAllContent(ctx, callback) {
  fmt.title('Read All Content ...')

  // make sure the 'content' dir exists
  fs.stat(ctx.cfg.contentDir, function(errStat, stats) {
    if (errStat) {
      if ( errStat.code === 'ENOENT' ) {
        // no error if it doesn't exist - just don't copy any files
        return process.nextTick(callback)
      }
      return callback(errStat)
    }

    // if this isn't a directory, then it's an error
    if ( !stats.isDirectory() ) {
      return callback(new Error('files directory ' + ctx.cfg.filesDir + ' is not a directory'))
    }

    find.file(ctx.cfg.contentDir, function(filenames) {

      // loop through each filename and read the contents
      async.eachSeries(
        filenames,
        function(filename, done) {
          // skip over backup files
          if ( filename.match(/~$/) ) {
            return done()
          }

          fs.readFile(filename, 'utf8', function(errReadFile, data) {
            if (errReadFile) return done(errReadFile)

            var name = filename.substr(ctx.cfg.contentDir.length)
            ctx.file[name] = data

            done()
          })
        },
        function(err) {
          if (err) callback(err)
          callback()
        }
      )
    }).error(callback)
  })
}
Beispiel #7
0
function seagull(opts, callback) {
  fmt.title('seagull(): entry')

  var cfg = xtend({}, DEFAULTS, opts)
  console.log('cfg:', cfg)

  var ctx = {
    now  : cfg.published ? new Date(cfg.published) : new Date(), // so all plugins can use exactly the same date
    cfg  : cfg,
    view : {}, // the Jade functions for views
    file : {}, // the raw     { '/about.md' : 'file contents' }
    page : {}, // the pages : { '/about' : { ...etc... } } // no hierarchy yet (e.g. no '/blog/', just '/blog/post.md'
    site : {}, // the site  : { '/' : { 'about' : { ... }}, '/blog/' : { 'first-post' : { ... } }} // with hierarchy
  }

  async.series(
    [
      cleanHtmlDir.bind(null, ctx),
      copyStaticFilesToHtml.bind(null, ctx),
      readAllContent.bind(null, ctx),
      processContentToPages.bind(null, ctx),
      loadUpJadeViews.bind(null, ctx),
      createSiteStructure.bind(null, ctx),
      createSitemap.bind(null, ctx),
      convertMarkdownToHtml.bind(null, ctx),
      processPosts.bind(null, ctx),
      createIndexPages.bind(null, ctx),
      createArchivePages.bind(null, ctx),
      createAtomFeeds.bind(null, ctx),
      createRssFeeds.bind(null, ctx),
      createOutputDirs.bind(null, ctx),
      renderSite.bind(null, ctx),
    ],
    function(err) {
      console.log('-------------------------------------------------------------------------------')
      console.log('err:', err)
      console.log('ctx:', ctx)
      console.log('-------------------------------------------------------------------------------')
      callback(err)
    }
  )
}
Beispiel #8
0
module.exports = function createAtomFeeds(ctx, callback) {
  fmt.title('Create Atom Feeds ...')

  visitEveryDir(
    ctx,
    function(url, dir, done) {
      // just get enough posts for the feed
      var posts = dir.posts.reverse().slice(0, ctx.cfg.postsPerPage)

      // firstly, do the main atom feed
      createFeed(ctx, url, dir, ctx.cfg.title, 'http://' + ctx.cfg.domain + url, ctx.cfg.authorName, ctx.cfg.authorEmail, posts, 'atom.xml')

      // now create all of the category feeds
      if ( dir.category ) {
        Object.keys(dir.category).forEach(function(catName) {
          var name = 'category-' + catName + '.xml'
          createFeed(ctx, url, dir, ctx.cfg.title, 'http://' + ctx.cfg.domain + url, ctx.cfg.authorName, ctx.cfg.authorEmail, dir.category[catName], name)
        })
      }

      // now create all of the tag feeds
      if ( dir.tag ) {
        Object.keys(dir.tag).forEach(function(tagName) {
          var name = 'tag-' + tagName + '.xml'
          createFeed(ctx, url, dir, ctx.cfg.title, 'http://' + ctx.cfg.domain + url, ctx.cfg.authorName, ctx.cfg.authorEmail, dir.tag[tagName], name)
        })
      }

      // now create all of the authors feeds
      if ( dir.author ) {
        Object.keys(dir.author).forEach(function(authorName) {
          var name = 'author-' + authorName + '.xml'
          createFeed(ctx, url, dir, ctx.cfg.title, 'http://' + ctx.cfg.domain + url, ctx.cfg.authorName, ctx.cfg.authorEmail, dir.author[authorName], name)
        })
      }

      process.nextTick(done)
    },
    callback
  )
}
Beispiel #9
0
				s3.GetObject(options, { stream : true }, function(err, data) {
					// stream this file to stdout
					fmt.title('Download Stream Started');
					res.attachment(dlName);
					data.Stream.pipe(res);
				});
Beispiel #10
0
var amazon = awssum.load('amazon/amazon');
var S3 = awssum.load('amazon/s3').S3;

var env             = process.env;
var accessKeyId     = env.ACCESS_KEY_ID;
var secretAccessKey = env.SECRET_ACCESS_KEY;
var awsAccountId    = env.AWS_ACCOUNT_ID;

var s3 = new S3({
    'accessKeyId' : accessKeyId,
    'secretAccessKey' : secretAccessKey,
    'region' : amazon.US_EAST_1
});

fmt.line();
fmt.title('s3.CopyObject');

fmt.field('Region', s3.region() );
fmt.field('EndPoint', s3.host() );
fmt.field('AccessKeyId', s3.accessKeyId() );
fmt.field('SecretAccessKey', s3.secretAccessKey().substr(0, 3) + '...' );
fmt.field('AwsAccountId', s3.awsAccountId() );

fmt.line();

var options = {
    BucketName : 'pie-18',
    ObjectName : 'copy-of-test-object.txt',
    SourceBucket : 'pie-18',
    SourceObject : 'test-object.txt',
};
 client.removeSnapshot(context.params.name, context.params.version, function () {
     fmt.title(client.remote.toString('long'));
     fmt.field(project.formatName(context.params), 'removed');
     next();
 });
 client.removeProject(context.params.name, function (msg) {
     msg = msg || 'removed';
     fmt.title(client.remote.toString('long'));
     fmt.field(context.params.name, msg);
     next();
 });
Beispiel #13
0
var amazon = awssum.load('amazon/amazon');
var S3 = awssum.load('amazon/s3').S3;

var env             = process.env;
var accessKeyId     = env.ACCESS_KEY_ID;
var secretAccessKey = env.SECRET_ACCESS_KEY;
var awsAccountId    = env.AWS_ACCOUNT_ID;

var s3 = new S3({
    'accessKeyId'     : accessKeyId,
    'secretAccessKey' : secretAccessKey,
    'region'          : amazon.US_EAST_1,
});

fmt.line();
fmt.title('s3.ListBuckets');

fmt.field('Region',          s3.region());
fmt.field('EndPoint',        s3.host() );
fmt.field('AccessKeyId',     s3.accessKeyId() );
fmt.field('SecretAccessKey', s3.secretAccessKey().substr(0, 3) + '...' );
fmt.field('AwsAccountId',    s3.awsAccountId() );

fmt.line();

s3.ListBuckets(function(err, data) {
    fmt.msg("listing all the buckets (no options given) - expecting success");
    fmt.dump(err,  'Error');
    fmt.dump(data, 'Data');
    fmt.line();
});