Skip to content

Commit

Permalink
minify param added
Browse files Browse the repository at this point in the history
  • Loading branch information
karaxuna committed Oct 23, 2014
1 parent d38ada1 commit ade4a81
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ Parameters must be saved in `ngtoast.json` or passed through command line:
"public": [path to public folder],
"modules": [relative path from public to modules folder],
"output": [output file name],
"minify": [if parameter is present output is minified]
"minify": [if parameter is present output is minified],
"relative": [if paths in result file must be relative]
}

Building concatenated file to serve to browser (will be saved in directory matching `output` parameter in configuration):
Expand Down
21 changes: 11 additions & 10 deletions commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ module.exports = function(args){
modulesScript,
modulesAbsPath = path.resolve(args.public, args.modules);

function normalizePath(p){
return p.split('\\').join('/');
}

fs.readdirSync(modulesAbsPath).forEach(function(mn){
var module = {
var module = {
name: mn,
path: normalizePath(path.join('/', args.modules, mn)),
main: fs.readFileSync(path.join(modulesAbsPath, mn, '/module.js'), 'utf8')
path: path.join(args.modules, mn),
main: fs.readFileSync(path.join(modulesAbsPath, mn, 'module.js'), 'utf8')
};

['controllers', 'directives', 'factories', 'filters'].forEach(function (n){
Expand All @@ -25,7 +21,7 @@ module.exports = function(args){
fs.readdirSync(path.join(modulesAbsPath, mn, n)).forEach(function(name){
t.push({
name: name,
path: normalizePath(path.join('/', args.modules, mn, n, name)),
path: path.join(args.modules, mn, n, name),
content: fs.readFileSync(path.join(modulesAbsPath, mn, n, name, '/index.js'), 'utf8')
});
});
Expand All @@ -49,7 +45,7 @@ module.exports = function(args){
.replace('=content=', item.content)
.replace('=item=', JSON.stringify({
name: item.name,
path: item.path
path: clientify(item.path)
}));
}).join('\n');
}
Expand All @@ -62,11 +58,16 @@ module.exports = function(args){
.replace('=filters=', wrap(module.filters))
.replace('=module=', JSON.stringify({
name: module.name,
path: module.path,
path: clientify(module.path),
dependencies: cmns
}));
}).join('\n');

function clientify(p){
p = (args.relative ? './' : '/') + p;
return p.split('\\').join('/');
}

fs.writeFileSync(args.output, args.minify ? uglifyJS.minify(modulesScript, { fromString: true }).code : modulesScript);
console.log('command executed successfully. file saved in ', path.resolve(args.output));
};
76 changes: 76 additions & 0 deletions npm-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
0 info it worked if it ends with ok
1 verbose cli [ 'c:\\Program Files (x86)\\nodejs\\node.exe',
1 verbose cli 'c:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'publish' ]
2 info using [email protected]
3 info using [email protected]
4 verbose publish [ '.' ]
5 verbose cache add [ '.', null ]
6 verbose cache add name=undefined spec="." args=[".",null]
7 verbose parsed url { protocol: null,
7 verbose parsed url slashes: null,
7 verbose parsed url auth: null,
7 verbose parsed url host: null,
7 verbose parsed url port: null,
7 verbose parsed url hostname: null,
7 verbose parsed url hash: null,
7 verbose parsed url search: null,
7 verbose parsed url query: null,
7 verbose parsed url pathname: '.',
7 verbose parsed url path: '.',
7 verbose parsed url href: '.' }
8 silly lockFile 3a52ce78- .
9 verbose lock . C:\Users\Karaxuna\AppData\Roaming\npm-cache\3a52ce78-.lock
10 verbose tar pack [ 'C:\\Users\\Karaxuna\\AppData\\Roaming\\npm-cache\\ngtoast\\0.1.7\\package.tgz',
10 verbose tar pack '.' ]
11 verbose tarball C:\Users\Karaxuna\AppData\Roaming\npm-cache\ngtoast\0.1.7\package.tgz
12 verbose folder .
13 info prepublish [email protected]
14 silly lockFile 1f1177db-tar tar://.
15 verbose lock tar://. C:\Users\Karaxuna\AppData\Roaming\npm-cache\1f1177db-tar.lock
16 silly lockFile fd19e394--cache-ngtoast-0-1-7-package-tgz tar://C:\Users\Karaxuna\AppData\Roaming\npm-cache\ngtoast\0.1.7\package.tgz
17 verbose lock tar://C:\Users\Karaxuna\AppData\Roaming\npm-cache\ngtoast\0.1.7\package.tgz C:\Users\Karaxuna\AppData\Roaming\npm-cache\fd19e394--cache-ngtoast-0-1-7-package-tgz.lock
18 silly lockFile 1f1177db-tar tar://.
19 silly lockFile 1f1177db-tar tar://.
20 silly lockFile fd19e394--cache-ngtoast-0-1-7-package-tgz tar://C:\Users\Karaxuna\AppData\Roaming\npm-cache\ngtoast\0.1.7\package.tgz
21 silly lockFile fd19e394--cache-ngtoast-0-1-7-package-tgz tar://C:\Users\Karaxuna\AppData\Roaming\npm-cache\ngtoast\0.1.7\package.tgz
22 silly lockFile aef493b8--npm-cache-ngtoast-0-1-7-package C:\Users\Karaxuna\AppData\Roaming\npm-cache\ngtoast\0.1.7\package
23 verbose lock C:\Users\Karaxuna\AppData\Roaming\npm-cache\ngtoast\0.1.7\package C:\Users\Karaxuna\AppData\Roaming\npm-cache\aef493b8--npm-cache-ngtoast-0-1-7-package.lock
24 silly lockFile aef493b8--npm-cache-ngtoast-0-1-7-package C:\Users\Karaxuna\AppData\Roaming\npm-cache\ngtoast\0.1.7\package
25 silly lockFile aef493b8--npm-cache-ngtoast-0-1-7-package C:\Users\Karaxuna\AppData\Roaming\npm-cache\ngtoast\0.1.7\package
26 silly lockFile 3a52ce78- .
27 silly lockFile 3a52ce78- .
28 silly publish { name: 'ngtoast',
28 silly publish description: 'angularjs package manager',
28 silly publish version: '0.1.7',
28 silly publish author: { name: 'Kakhaber Bazerashvili' },
28 silly publish homepage: 'https://github.com/karaxuna/ngtoast',
28 silly publish repository: { type: 'git', url: 'git://github.com/karaxuna/ngtoast.git' },
28 silly publish license: 'MIT',
28 silly publish engines: { node: '>= 0.4.0' },
28 silly publish dependencies:
28 silly publish { optimist: '',
28 silly publish jszip: '',
28 silly publish walk: '',
28 silly publish async: '',
28 silly publish mkdirp: '',
28 silly publish 'uglify-js': '',
28 silly publish chokidar: '' },
28 silly publish bin: { ngtoast: 'bin/ngtoast.bin.js' },
28 silly publish gitHead: 'd38ada1b69265598123a59cd565dad34bc7807ea',
28 silly publish readme: '# ngtoast\r\n\r\nPackage manager for angularjs\r\n\r\n## Installation:\r\n\r\n npm install ngtoast\r\n\r\n## File structure ([example](https://github.com/karaxuna/ngtoast-example)):\r\n\r\n -public\r\n -modules\r\n -[module]\r\n -directives\r\n -[directive name]\r\n -index.js\r\n -controllers\r\n -[controller name]\r\n -index.js\r\n -filters\r\n -[filter name]\r\n -index.js\r\n -factories\r\n -[factory name]\r\n -index.js\r\n -views\r\n -[view name]\r\n -module.js\r\n -[module].[child]\r\n ... same here\r\n -ngtoast.json\r\n \r\n## Config\r\n\r\nParameters must be saved in `ngtoast.json` or passed through command line:\r\n\r\n {\r\n \t"public": [path to public folder],\r\n "modules": [relative path from public to modules folder],\r\n "output": [output file name],\r\n "minify": [if parameter is present output is minified]\r\n }\r\n \r\nBuilding concatenated file to serve to browser (will be saved in directory matching `output` parameter in configuration):\r\n\r\n ngtoast build\r\n\r\n## Output\r\n\r\nFile will contain all modules, directives, factories, controllers and filters of application. Each of them will have additional parameters supplied:\r\n\r\n module: {\r\n name: [module name],\r\n path: [module path],\r\n dependencies: [array of child module names]\r\n },\r\n \r\n current: {\r\n name: [current directive/filter/factory/controller name],\r\n path: [path]\r\n }\r\n \r\nExample (`[module]/module.js`):\r\n\r\n```javascript\r\nangular\r\n .module(module.name, [\'ui.router\'].concat(module.dependencies.concat))\r\n .config([\'$stateProvider\', function(stateProvider){\r\n stateProvider\r\n .state(module.name, {\r\n url: [module url],\r\n templateUrl: module.path + \'/views/[view name]\',\r\n // controller name is prefixed to avoid conflict\r\n controller: module.name + \'.c.[controller name]\'\r\n });\r\n }]);\r\n```\r\n \r\nExample (`[module]/controllers/[controller name]/index.js`):\r\n\r\n```javascript\r\nangular.module(module.name).controller(module.name + \'.c.\' + current.name,\r\n [\'$scope\', function(scope){\r\n ...\r\n }]);\r\n```\r\n\r\n## Watch modules folder and call `ngtoast build` each time something changes\r\n\r\n ngtoast watch\r\n\r\n## Remote packages (not implemented yet!)\r\n\r\ninstalling:\r\n\r\n ngtoast install [remote package name] --module [module name] --parent [parent module name] --as [changed module name]\r\n\r\nuninstalling:\r\n\r\n ngtoast uninstall [package name]\r\n\r\npublishing:\r\n\r\n ngtoast publish [package name]',
28 silly publish readmeFilename: 'README.md',
28 silly publish bugs: { url: 'https://github.com/karaxuna/ngtoast/issues' },
28 silly publish _id: '[email protected]',
28 silly publish scripts: {},
28 silly publish _shasum: 'a14d99ebab497ff0e73935ed25a5c1932f5d7a37',
28 silly publish _from: '.' }
29 error need auth auth and email required for publishing
29 error need auth You need to authorize this machine using `npm adduser`
30 error System Windows_NT 6.2.9200
31 error command "c:\\Program Files (x86)\\nodejs\\node.exe" "c:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "publish"
32 error cwd C:\Users\Karaxuna\Desktop\ngtoast
33 error node -v v0.10.32
34 error npm -v 1.4.28
35 error code ENEEDAUTH
36 verbose exit [ 1, true ]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ngtoast",
"description": "angularjs package manager",
"version": "0.1.7",
"version": "0.1.8",
"author": "Kakhaber Bazerashvili",
"homepage": "https://github.com/karaxuna/ngtoast",
"repository": "git://github.com/karaxuna/ngtoast.git",
Expand Down

0 comments on commit ade4a81

Please sign in to comment.