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QAAU,CACf,iBAAkB,iBAClB,MAAO","file":"/npm/kom@0.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/kom@0.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var exec = require('child_process').exec;\nvar path = require('path');\nvar fs = require('fs.extra');\nvar util = require(\"util\")\n\nvar through = require('through');\nvar browserify = require('browserify');\nvar async = require('async');\nvar concat = require('concat-stream');\nvar CombinedStream = require('combined-stream');\nvar glob = require('glob');\n\nvar findPackage = require('./lib/pkgfinder');\n\nfunction findDependencies(entry) {\n  var seen = {};\n  var b = browserify();\n  b.add(path.resolve(entry));\n  var depstream = b.deps({});\n\n  return depstream.pipe(through(function(dep) {\n      var out = this;\n\n      findPackage(path.dirname(dep.id), function(err, pkg, pkgfile) {\n        if(err) return out.emit('error', err);\n\n        if(!pkgfile.komponent) return;\n        if(seen[pkg]) return;\n\n        seen[pkg] = true;\n        out.queue({ pkg: pkg, pkgfile: pkgfile });\n      });\n    }))\n};\n\nfunction build(entry, opts) {\n\n  opts = opts || {};\n\n  var buildDir = path.resolve('build');\n\n  findPackage(path.resolve(entry), function(err, _pkg, _pkgfile) {\n\n    var rootPackage = _pkgfile;\n\n    console.log('Building %s\\n', rootPackage.name);\n\n    async.waterfall([\n\n      function cleanBuildDirectory(cb) {\n        console.log('  - cleaning build directory');\n        fs.rmrf(buildDir, function() {\n          fs.mkdir(buildDir, cb);\n        });\n      },\n\n      function buildDependencies(cb) {\n        findDependencies(entry).pipe(concat(function(deps) {\n          var tasks = deps.map(function(dep) {\n            return buildOne.bind(null, dep);\n          });\n          async.parallel(tasks, cb);\n        }))\n      },\n\n      function concatenateCss(_, cb) {\n        console.log('  - concatenating stylesheets');\n\n        // options is optional\n        glob(path.join(buildDir, \"**/*.css\"), function (er, files) {\n          var combinedStream = CombinedStream.create();\n          combinedStream.append('/* Styles concatenated using komponent */\\n');\n\n          // FIXME: preserve order of concatenated stylesheets files - the\n          // top-level ones should go last, so they override nested ones.\n          files.forEach(function(file) {\n            var name = path.basename(path.dirname(file));\n            if(name === 'build') name = rootPackage.name;\n\n            combinedStream.append(util.format('\\n/* BEGIN styles for \"%s\" */\\n', name));\n            combinedStream.append(fs.createReadStream(file));\n            combinedStream.append(util.format('\\n/* END styles for \"%s\" */\\n', name));\n          });\n\n          combinedStream.pipe(fs.createWriteStream(path.join(buildDir, '_style.css')));\n          combinedStream.on('end', function(err) {\n            if(err) return cb(err);\n            fs.rename(\n              path.join(buildDir, '_style.css'),\n              path.join(buildDir, 'style.css'),\n            cb);\n          });\n        })\n      },\n\n      function buildIndex(cb) {\n        var out = fs.createWriteStream('build/index.js');\n        entry = path.resolve(entry);\n        var b = browserify();\n        b.transform('brfs');\n        b.add(entry);\n\n        var bundle = b.bundle({\n          debug: !!opts.debug,\n          standalone: opts['global-name'] || rootPackage.name\n        });\n        bundle\n          .on('error', cb)\n          .on('end', cb)\n          .pipe(out);\n      },\n      function done() {\n        // TODO: print total bundle size and list of assets\n        console.log('\\nAll done! Bundled komponent and dependencies are in ./%s',\n            path.relative(process.cwd(), buildDir));\n      }\n\n    ]);\n\n  });\n\n\n  function buildOne(komponent, cb) {\n    var dir = path.dirname(komponent.pkg),\n        pkgname = komponent.pkgfile.name;\n\n    console.log('  - building assets for \"%s\" in %s', pkgname, dir);\n\n    async.series([\n      function prepublish(cb) {\n        var child = exec('npm run-script prepublish', {\n          cwd: dir\n        }, function (error, stdout, stderr) {\n          if (error !== null) {\n            console.log('exec error: ' + error);\n          }\n          cb();\n        });\n      },\n      function copyAssets() {\n        var dst = path.join(buildDir, pkgname),\n            pkgBuildDir = path.join(path.dirname(komponent.pkg), 'build');\n\n        if(pkgBuildDir === buildDir) return cb();\n\n        fs.copyRecursive(pkgBuildDir, dst, cb);\n      }\n    ]);\n\n\n    // TODO:\n    // 1. create a directory A in the build/ directory for the komponent\n    // 2. run `npm prepublish` and copy all resulting assets to the directory\n    // created in 1.\n  }\n\n};\n\nmodule.exports = {\n  findDependencies: findDependencies,\n  build: build\n};\n"]}