@zendesk/zcli-apps
Advanced tools
Comparing version 1.0.0-beta.10 to 1.0.0-beta.11
@@ -6,2 +6,10 @@ # Change Log | ||
# [1.0.0-beta.11](https://github.com/zendesk/zcli/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2021-11-21) | ||
**Note:** Version bump only for package @zendesk/zcli-apps | ||
# [1.0.0-beta.10](https://github.com/zendesk/zcli/compare/v1.0.0-beta.8...v1.0.0-beta.10) (2021-11-10) | ||
@@ -8,0 +16,0 @@ |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Command, flags } from '@oclif/command'; | ||
@@ -18,3 +17,5 @@ export default class Server extends Command { | ||
static strict: boolean; | ||
run(): Promise<import("http").Server>; | ||
run(): Promise<{ | ||
close: () => void; | ||
}>; | ||
} |
@@ -8,2 +8,3 @@ "use strict"; | ||
const cors = require("cors"); | ||
const fs = require("fs"); | ||
const buildAppJSON_1 = require("../../lib/buildAppJSON"); | ||
@@ -19,3 +20,3 @@ const shared_1 = require("../../utils/shared"); | ||
const appPaths = shared_1.getAppPaths(appDirectories); | ||
const appJSON = await buildAppJSON_1.buildAppJSON(appPaths, port); | ||
let appJSON = await buildAppJSON_1.buildAppJSON(appPaths, port); | ||
const app = express(); | ||
@@ -28,6 +29,19 @@ app.use(cors()); | ||
}); | ||
appJSON.installations.forEach((installation, index) => { | ||
app.use(`/${installation.app_id}/assets`, express.static(`${appPaths[index]}/assets`)); | ||
}); | ||
return app.listen(port, host, () => { | ||
const setAppAssetsMiddleware = () => { | ||
appJSON.installations.forEach((installation, index) => { | ||
app.use(`/${installation.app_id}/assets`, express.static(`${appPaths[index]}/assets`)); | ||
}); | ||
}; | ||
// Keep references of watchers for unwatching later | ||
const watchers = appPaths.map(appPath => fs.watch(appPath, async (eventType, filename) => { | ||
if (filename.toLowerCase() === 'manifest.json') { | ||
// Regenerate app.json | ||
appJSON = await buildAppJSON_1.buildAppJSON(appPaths, port); | ||
// Reset middlewares for app assets | ||
setAppAssetsMiddleware(); | ||
} | ||
})); | ||
// Set middlewares for app assets | ||
setAppAssetsMiddleware(); | ||
const server = app.listen(port, host, () => { | ||
this.log(`\nApps server is running on ${chalk.green(`http://${host}:${port}`)} 🚀\n`); | ||
@@ -37,2 +51,9 @@ this.log(`Add ${chalk.bold('?zcli_apps=true')} to the end of your Zendesk URL to load these apps on your Zendesk account.\n`); | ||
}); | ||
return { | ||
close: () => { | ||
// Stop watching file changes before terminating the server | ||
watchers.forEach(watcher => watcher.close()); | ||
server.close(); | ||
} | ||
}; | ||
} | ||
@@ -39,0 +60,0 @@ } |
{ | ||
"name": "@zendesk/zcli-apps", | ||
"description": "zcli apps commands live here", | ||
"version": "1.0.0-beta.10", | ||
"version": "1.0.0-beta.11", | ||
"author": "@vegemite", | ||
@@ -78,3 +78,3 @@ "npmRegistry": "https://registry.npmjs.org", | ||
"types": "lib/index.d.ts", | ||
"gitHead": "809837c4e240df1edb43f04691c3275e9313d555" | ||
"gitHead": "cc1c5cc66c037cbc6a9a9d184aefe07a1b383cb7" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
79758
1662
17
2