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

Create configurations that can be used with YUI.applyConfig function for external modules #83

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
4 changes: 3 additions & 1 deletion lib/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ var nopt = require('nopt'),
outfile: path,
loglevel: [ 'silent', 'info', 'debug', 'warn' ],
lint: [ 'defaults', 'strict', 'preferred' ],
filter: [ 'raw', 'min', 'debug', 'coverage' ]
filter: [ 'raw', 'min', 'debug', 'coverage' ],
externalModules: Boolean,
modulesPattern: String
},
shorts = {
'y' : ['--yes'],
Expand Down
83 changes: 60 additions & 23 deletions lib/cmds/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,27 @@ mods = {
this.mix = this.options.parsed.mix || false;

this.strict = this.options.parsed.strict || false;

this.externalModules = !!this.options.parsed.externalModules || false;

this.configPath = this.configPath || path.resolve(this.start, 'loader/js/config.js');

this.modulesPattern = ((typeof this.options.parsed.modulesPattern === 'string') ? this.options.parsed.modulesPattern : '@MODULES@');

this.json = this.options.parsed.json || path.join(this.start, 'loader/js/yui3.json');
if (this.externalModules) {
this.json = this.options.parsed.json || path.join(this.start, 'loader/js/generated-config.json');

this.js = this.options.parsed.js || path.join(this.start, 'loader/js/generated-config.js');

this.js = this.options.parsed.js || path.join(this.start, 'loader/js/yui3.js');
this.tests = false;
}
else {
this.json = this.options.parsed.json || path.join(this.start, 'loader/js/yui3.json');

this.tests = this.options.parsed.tests || path.join(this.start, 'yui/js/load-tests.js');
this.js = this.options.parsed.js || path.join(this.start, 'loader/js/yui3.js');

this.tests = this.options.parsed.tests || path.join(this.start, 'yui/js/load-tests.js');
}

this.group = this.options.parsed.group;

Expand Down Expand Up @@ -354,28 +369,48 @@ mods = {
'/* This file is auto-generated by (' + this.baseCMD + ') */',
'',
'/*jshint maxlen:900, eqeqeq: false */',
'',
'/**',
' * YUI 3 module metadata',
' * @module loader',
' * @submodule loader-yui3',
' */'
];

if (this.mix) {
log.info('using mix to assign meta-data');
str.push('YUI.Env[Y.version].modules = YUI.Env[Y.version].modules || {};');
str.push('Y.mix(YUI.Env[Y.version].modules, { /* METAGEN */ });');
} else {
str.push('YUI.Env[Y.version].modules = YUI.Env[Y.version].modules || { /* METAGEN */ };');
''
],
configData;

if (this.externalModules) {
log.info('Creating apply configuration.');
// creates a YUI global config call.
str = str.concat([
'/**',
' * YUI 3 externalModules',
' *',
' * MD5: { /* MD5 */ }',
' */'
]);

configData = fs.readFileSync(this.configPath, {'encoding': 'utf8'});
str.push(configData.replace(this.modulesPattern, TEMPLATE_TOKEN));
}
else {
str = str.concat([
'/**',
' * YUI 3 module metadata',
' * @module loader',
' * @submodule loader-yui3',
' */'
]);

if (this.mix) {
log.info('using mix to assign meta-data');
str.push('YUI.Env[Y.version].modules = YUI.Env[Y.version].modules || {};');
str.push('Y.mix(YUI.Env[Y.version].modules, { /* METAGEN */ });');
} else {
str.push('YUI.Env[Y.version].modules = YUI.Env[Y.version].modules || { /* METAGEN */ };');
}

str.push("YUI.Env[Y.version].md5 = '{ /* MD5 */ }';");
str.push('');
str.push("YUI.Env[Y.version].md5 = '{ /* MD5 */ }';");
str.push('');

if (this.name) {
str.unshift('YUI.add("' + this.name + '", function(Y, NAME) {');
str.push('});');
if (this.name) {
str.unshift('YUI.add("' + this.name + '", function(Y, NAME) {');
str.push('});');
}
}

return str.join('\n');
Expand All @@ -392,7 +427,9 @@ mods = {
'--mix use mix to mix the module meta-data into an existing object (for gallery builds)',
'--strict only parse meta files that also have a build.json (default: false, true for gallery)',
'--expand Use Loader to pre-expand module meta data',
'--name Wrap the YUI.add wrapper and name the module'
'--name Wrap the YUI.add wrapper and name the module',
'--externalModules Replaces the modules pattern in YUI config.js',
'--modulesPattern Pattern used to insert modules (Default is @MODULES@)'
];
}
};
Expand Down