{"id":14975415,"url":"https://github.com/jquery/node-packager","last_synced_at":"2025-10-19T11:30:17.213Z","repository":{"id":26917663,"uuid":"30379763","full_name":"jquery/node-packager","owner":"jquery","description":"Build a package for your library or application on the fly on Node.js","archived":false,"fork":false,"pushed_at":"2024-04-15T22:12:37.000Z","size":24,"stargazers_count":2,"open_issues_count":0,"forks_count":5,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-01-29T13:03:38.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jquery.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-05T21:37:39.000Z","updated_at":"2023-04-10T01:44:12.000Z","dependencies_parsed_at":"2024-06-21T17:53:14.093Z","dependency_job_id":"4108625c-cf7b-456a-828a-cf8f469db6b4","html_url":"https://github.com/jquery/node-packager","commit_stats":{"total_commits":28,"total_committers":3,"mean_commits":9.333333333333334,"dds":0.0714285714285714,"last_synced_commit":"9758624fe031f4f264be5fd1555c7405f813ffd3"},"previous_names":["rxaviers/node-packager"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquery%2Fnode-packager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquery%2Fnode-packager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquery%2Fnode-packager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jquery%2Fnode-packager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jquery","download_url":"https://codeload.github.com/jquery/node-packager/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237116308,"owners_count":19258227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:51:59.963Z","updated_at":"2025-10-19T11:30:16.868Z","avatar_url":"https://github.com/jquery.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Why node-packager?\n\nUse `node-packager` to generate the built package for your library or application.\n\nIt's ideal for applications that builds packages on the fly using [Node.js][].\n\n[Node.js]: http://nodejs.org/\n\n## Usage\n\npackage.js:\n\n```javascript\nfunction Package() {}\n\nextend( Package.prototype, {\n\n  // Shallow copy\n  \"LICENSE.txt\": \"LICENSE.txt\",\n\n  // Sync processing\n  \"app.css\": function() {\n\n    // Return a String or Buffer with the file data.\n    return buildCss();\n  },\n\n  // Async processing\n  \"app.js\": function( callback ) {\n\n    // Call `callback( error, data )`, where data is a String with the file data.\n    buildJs( callback );\n  },\n\n  \"images/\": function() {\n    var files, imagesFiles;\n\n    // this.files and this.runtime are available.\n    if ( this.runtime.includeImages ) {\n      files = this.files;\n      imagesFiles = {};\n      Object.keys( this.files ).filter(function( filepath ) {\n        return minimatch( filepath, \"src/images/*\" );\n      }).forEach(function( filepath ) {\n        imagesFiles[ path.basename( filepath ) ] = files[ filepath ];\n      });\n      return imagesFiles\n    }\n\n    // Skip \"images/\" by returning null.\n    return null;\n  }\n});\n\nmodule.exports = Package;\n```\n\n   npm install node-packager\n\n```javascript\nvar fs = require( \"js\" );\nvar glob = require( \"glob\" );\nvar extend = require( \"util\" )._extend;\nvar Package = require( \"./package\" )\nvar Packager = require( \"node-packager\" );\n\nvar files = glob.sync( \"+(LICENSE.txt|src/**)\", { nodir: true } ).reduce(function( files, filepath ) {\n  files[ filepath ] = fs.readFileSync( filepath );\n  return files;\n}, {} );\n\nvar pkg = Packager( files, Package, {\n  includeImages: true\n});\nvar stream = fs.createWriteStream( \"myapp.zip\" );\npkg.toZip( stream, function( error ) {\n  if ( error ) {\n    return console.error( error );\n  }\n  console.log( \"Built myapp.zip (\" + pkg.stats.toZip.size + \" bytes) in \" + ( pkg.stats.build.time + pkg.stats.toZip.time ) + \" ms\" );\n  console.log( \"- app.js took \" + pkg.stats[ \"app.js\" ].time + \" ms\" );\n});\n```\n\n## API\n\n- **`Packager( files, Package [, runtimeVars] )`**\n\n**files** *Object* containing (path, data) key-value pairs, e.g.,\n\n```\n{\n   \u003cpath-of-file-1\u003e: \u003cdata-of-file-1\u003e,\n   \u003cpath-of-file-2\u003e: \u003cdata-of-file-2\u003e,\n   ...\n}\n```\n\nFiles will be available on Package via `this.files` attribute.\n\n**Package** *Function/Class* The Package class.\n\n**runtimeVars** *Object* Optional object including runtime variables.\n\nRuntime variables will be available on Package via `this.runtime` attribute.\n\n- **`Packager.prototype.toJson( callback )`**\n\n**callback** *Function* called with two arguments: null or an Error object and the built files\nobject.\n\n- **`Packager.prototype.toZip( target [, options], callback )`**\n\n**target** *Stream/String* The target stream, or the target filename (when string).\n\n**options** *Object*\n\n  **options.basedir** *String* Set the ZIP base directory.\n\n**callback** *Function* called when write is complete, with one argument: null or\nan Error object.\n\n\n## Test\n\n    npm test\n\n## License\n\nMIT © [Rafael Xavier de Souza](http://rafael.xavier.blog.br)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjquery%2Fnode-packager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjquery%2Fnode-packager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjquery%2Fnode-packager/lists"}