Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runnable as npm module. #29

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env node

var fs = require('fs');
var meteorBuildClient = require('./index.js');
var packageJson = require('./package.json');

// CLI Options
var program = require('commander');

// VARIABLES
var argPath = process.argv[2];


program
.version(packageJson.version)
.usage('<output path> [options]')
.option('-i, --input <path>', 'The path to the meteor project.')
.option('-p, --path <path>', 'The path used to link the files, default is "/", pass "" to link relative to the index.html.')
.option('-t, --template <file path>', 'Provide a custom index.html template. Use {{> head}}, {{> css}} and {{> scripts}} to place the meteor resources.')
.option('-s, --settings <settings.json>', 'Set optional data for Meteor.settings in your application.')
.option('-u, --url <url>', 'The Root URL of your app. If "default", Meteor will try to connect to the Server where it was served from. Default is: "" (empty string)')
// .option('-d, --ddp <url>', 'The URL of your Meteor DDP server, e.g. "ddp+sockjs://ddp.myapp.com/sockjs". If you don\'t add any it will also add call "Meteor.disconnect();" to prevent the app from conneting.')
.parse(process.argv);


// RUN TASKS

if(!argPath) {
console.error('You need to provide a path for the build output, for example:');
console.error('$ meteor-build-client myBuildFolder');

} else {

// start building the meteor client
meteorBuildClient({
input: program.input,
output: argPath,
template: program.template,
settings: program.settings,
url: program.url,
path: program.path,
feedback: true,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feedback=true will output console messages.

}, function(err) {
if (err) {
console.error(err);
}
});
}





1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{{> css}}
{{> scripts}}
{{> head}}
<meta charset="UTF-8">
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, special characters are not preserved in my test case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same issue. I saw it in FontAwesome rendering strange characters instead of Unicode.

</head>
<body>
</body>
Expand Down
96 changes: 96 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
var fs = require('fs');
var path = require('path');
var Queue = require('./queue');
var meteor = require('./meteor.js');
var _ = require('underscore');

function meteorBuildClient(config, done) {
config = _.clone(config || {});
done = _.isFunction(done) ? done : function(){};

_.defaults(config, {
input: './',
output: './.meteor-build',
template: null,
settings: null, // path or object
url: null,
path: "/",
feedback: false, // output console messages
});

config.input = path.resolve(config.input);
config.output = path.resolve(config.output);

if (_.isString(config.template))
config.template = path.resolve(config.template);
if (_.isString(config.settings))
config.settings = path.resolve(config.settings);

config.bundleName = path.basename(config.input);

// Build queue syncron
var queue = new Queue();


// check if in meteor folder
try {
if(!fs.lstatSync(path.join(config.input, '.meteor')).isDirectory())
throw new Error();

} catch(e) {
done('You\'re not in a Meteor app folder or inside a sub folder of your app.');
return;
}

// check template file
if(config.template) {
try {
if(!fs.lstatSync(config.template).isFile())
throw new Error();

} catch(e) {
done('The template file "'+ config.template +'" doesn\'t exist or is not a valid template file');
return;
}
}

// build meteor
queue.add(function(callback){
if (config.feedback)
console.log('Bundling Meteor app...');
meteor.build(config, callback);
});

// move the files into the build folder
queue.add(function(callback){
if (config.feedback)
console.log('Generating the index.html...');
meteor.move(config, callback);
});

// create the index.html
queue.add(function(callback){
meteor.addIndexFile(config, callback);
});

// delete unecessary fiels
queue.add(function(callback){
meteor.cleanUp(config, function(){
if (config.feedback) {
console.log('Done!');
console.log('-----');
console.log('You can find your files in "'+ config.output +'".');
}
callback();
});
});

// done
queue.add(function() {
done(null);
});

queue.run();
}

module.exports = meteorBuildClient;
100 changes: 0 additions & 100 deletions main.js

This file was deleted.

Loading