chore: service progress

This commit is contained in:
calebboyd
2017-10-02 18:02:32 -05:00
parent 4ef98bdc8a
commit 927820a5ec
6 changed files with 83 additions and 18 deletions
+2 -3
View File
@@ -129,7 +129,7 @@ compile({
- #### `make: string[]`
- Array of arguments for the node build make step, on windows this step recieves options for vcBuild.bat
- default: `[]` or `['nosign', 'release']` for non windows systems
- #### `make: string[]`
- #### `vcBuild: string[]`
- Alias for `make` option
- #### `snapshot: string`
- path to a file to be used as the warmup snapshot for the build
@@ -180,8 +180,7 @@ compile({
Patches and Plugins are just a middleware functions that take two arguments, the `compiler`, and `next`. The compiler is described below, and `next` ensures that the pipeline continues. Its invocation should always be awaited or returned to ensure correct behavior. Patches also require that [`--build`](#build-boolean) be set, while plugins do not.
For examples, see the built in patches: [src/patches](src/patches)
A plugin
For examples, see the built in patches: [src/patches](src/patches).
### `NexeCompiler`
+5 -3
View File
@@ -2,21 +2,23 @@
"name": "nexe-daemon",
"version": "1.0.0",
"description": "Plugin for nexe to create installable services",
"main": "index.js",
"main": "lib/index.js",
"scripts": {
"clean": "rimraf *.js",
"build": "tsc",
"postpublish": "npm run clean"
},
"files": [
"*.js",
"lib",
"winsw.exe"
],
"author": "Caleb Boyd",
"license": "MIT",
"devDependencies": {
"nexe": "^2.0.0-rc.6",
"rimraf": "^2.6.2",
"typescript": "^2.5.2"
},
"dependencies": {
"nexe": "^2.0.0-rc.11"
}
}
+3 -4
View File
@@ -22,13 +22,12 @@ export default function daemon (compiler: NexeCompiler<DaemonOptions>, next: ()
if (compiler.target.platform !== 'windows') {
return next()
}
compiler.addResource(
'./nexe/plugin/daemon/winsw.exe',
readFileSync(require.resolve('./winsw.exe'))
readFileSync(require.resolve('../winsw.exe'))
)
const name = compiler.options.name,
options = compiler.options.daemon.windows,
options = compiler.options.daemon && compiler.options.daemon.windows || {},
defaults: NexeDaemonOptions = {
id: name,
name,
@@ -37,7 +36,7 @@ export default function daemon (compiler: NexeCompiler<DaemonOptions>, next: ()
}
compiler.addResource(
'./nexe/plugin/daemon/winsw-config.xml',
'./nexe/plugin/daemon/winsw.xml',
Buffer.from(renderWinswConfig(Object.assign(defaults, options)))
)
compiler.addResource(
+68 -3
View File
@@ -1,4 +1,69 @@
console.log('hello world')
if (true) {
console.log('wat')
const installCommands = ['-i', '--install']
const installIndex = process.argv.findIndex(x => installCommands.includes(x))
import * as path from 'path'
import * as fs from 'fs'
import * as cp from 'child_process'
function mkdirp (r: string, t?: any): any {
;(t = t || null), (r = path.resolve(r))
try {
fs.mkdirSync(r), (t = t || r)
} catch (c) {
if ('ENOENT' === c.code) (t = mkdirp(path.dirname(r), t)), mkdirp(r, t)
else {
var i
try {
i = fs.statSync(r)
} catch (r) {
throw c
}
if (!i.isDirectory()) throw c
}
}
return t
}
if (~installIndex) {
console.log('DIRECTORY FOUND')
const directory = process.argv[installIndex + 1]
if (directory) {
mkdirp(path.dirname(directory))
const filename = path.join(directory, path.basename(process.execPath))
const readStream = fs.createReadStream(process.execPath)
const writeStream = fs.createWriteStream(filename)
const onError = function () {
readStream.removeAllListeners()
writeStream.removeAllListeners()
//TODO
}
readStream
.on('error', onError)
.pipe(writeStream)
.on('error', onError)
.on('close', () => {
const winsw = filename.replace('.exe', '-service.exe')
fs.writeFileSync(
winsw,
fs.readFileSync('./nexe/plugin/daemon/winsw.exe')
)
fs.writeFileSync(
filename.replace('.exe', '-service.xml'),
fs.readFileSync('./nexe/plugin/daemon/winsw.xml')
)
installService(winsw)
})
}
} else {
console.log("DIRECTORY NOT FOUND")
require('./nexe/plugin/daemon/app.js')
}
function installService (filename: string) {
cp.exec(filename + ' install', (error) => {
if (error && !error.message.includes('already exists')) {
throw error
}
})
}
+3 -3
View File
@@ -1458,9 +1458,9 @@ negotiator@0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9"
nexe@^2.0.0-rc.6:
version "2.0.0-rc.6"
resolved "https://registry.yarnpkg.com/nexe/-/nexe-2.0.0-rc.6.tgz#b3990bb67098a93bc488b21ad88aee67b62cf0d5"
nexe@^2.0.0-rc.11:
version "2.0.0-rc.11"
resolved "https://registry.yarnpkg.com/nexe/-/nexe-2.0.0-rc.11.tgz#cd06fc91da8db008fffa6dde1a9a8dd6decf2c35"
dependencies:
app-builder "^5.1.0"
chalk "^1.1.3"
+2 -2
View File
@@ -241,8 +241,8 @@ function normalizeOptionsAsync(input?: Partial<NexeOptions>): Promise<NexeOption
return x
}
options.plugins = options.plugins.map(requireDefault)
options.patches = options.patches.map(requireDefault)
options.plugins = flatten(opts.plugin, options.plugins).map(requireDefault)
options.patches = flatten(opts.patch, options.patches).map(requireDefault)
Object.keys(alias)
.filter(k => k !== 'rc')