@ms-cloudpack/cli 0.47.10 → 0.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/cache/clean.d.ts +4 -0
- package/lib/commands/cache/clean.d.ts.map +1 -0
- package/lib/commands/cache/clean.js +24 -0
- package/lib/commands/cache/clean.js.map +1 -0
- package/lib/commands/cache/index.d.ts.map +1 -0
- package/lib/commands/cache/index.js +14 -0
- package/lib/commands/cache/index.js.map +1 -0
- package/lib/commands/start/appServer/createRoutes.d.ts.map +1 -1
- package/lib/commands/start/appServer/createRoutes.js +3 -4
- package/lib/commands/start/appServer/createRoutes.js.map +1 -1
- package/lib/commands/start/appServer/getHtmlResponse.d.ts +2 -2
- package/lib/commands/start/appServer/getHtmlResponse.d.ts.map +1 -1
- package/lib/commands/start/appServer/getHtmlResponse.js +14 -19
- package/lib/commands/start/appServer/getHtmlResponse.js.map +1 -1
- package/lib/commands/start/appServer/setHeaders.d.ts.map +1 -1
- package/lib/commands/start/appServer/setHeaders.js +0 -1
- package/lib/commands/start/appServer/setHeaders.js.map +1 -1
- package/lib/commands/start/getStartingAppPath.js +2 -2
- package/lib/commands/start/getStartingAppPath.js.map +1 -1
- package/package.json +4 -5
- package/lib/commands/dashboard/index.d.ts.map +0 -1
- package/lib/commands/dashboard/index.js +0 -7
- package/lib/commands/dashboard/index.js.map +0 -1
- /package/lib/commands/{dashboard → cache}/index.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../../src/commands/cache/clean.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,iCAAiC;AACjC,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,SAAS,CAqB5C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getCachePath } from '@ms-cloudpack/api-server';
|
|
2
|
+
import fsPromises from 'fs/promises';
|
|
3
|
+
/** Clear the Cloudpack cache. */
|
|
4
|
+
export const execute = async ({ cwd, initialize, exit }) => {
|
|
5
|
+
await initialize(cwd);
|
|
6
|
+
const cachePath = getCachePath();
|
|
7
|
+
const cacheDescription = `the Cloudpack cache (${cachePath})`;
|
|
8
|
+
let message;
|
|
9
|
+
let hasErrors = false;
|
|
10
|
+
try {
|
|
11
|
+
await fsPromises.rm(cachePath, { recursive: true, force: true });
|
|
12
|
+
message = `Successfully cleared ${cacheDescription}`;
|
|
13
|
+
hasErrors = false;
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
message = `Failed to clear ${cacheDescription}: ${err.message || err}`;
|
|
17
|
+
hasErrors = true;
|
|
18
|
+
}
|
|
19
|
+
await exit({
|
|
20
|
+
exitCode: hasErrors ? 1 : 0,
|
|
21
|
+
message,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=clean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clean.js","sourceRoot":"","sources":["../../../src/commands/cache/clean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,UAAU,MAAM,aAAa,CAAC;AAGrC,iCAAiC;AACjC,MAAM,CAAC,MAAM,OAAO,GAA6B,KAAK,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE;IACnF,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IAEtB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,MAAM,gBAAgB,GAAG,wBAAwB,SAAS,GAAG,CAAC;IAC9D,IAAI,OAAe,CAAC;IACpB,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,IAAI;QACF,MAAM,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,OAAO,GAAG,wBAAwB,gBAAgB,EAAE,CAAC;QACrD,SAAS,GAAG,KAAK,CAAC;KACnB;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,GAAG,mBAAmB,gBAAgB,KAAM,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC;QAClF,SAAS,GAAG,IAAI,CAAC;KAClB;IAED,MAAM,IAAI,CAAC;QACT,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { getCachePath } from '@ms-cloudpack/api-server';\nimport fsPromises from 'fs/promises';\nimport type { CommandAction } from '../../types/CommandAction.js';\n\n/** Clear the Cloudpack cache. */\nexport const execute: CommandAction<undefined> = async ({ cwd, initialize, exit }) => {\n await initialize(cwd);\n\n const cachePath = getCachePath();\n const cacheDescription = `the Cloudpack cache (${cachePath})`;\n let message: string;\n let hasErrors = false;\n\n try {\n await fsPromises.rm(cachePath, { recursive: true, force: true });\n message = `Successfully cleared ${cacheDescription}`;\n hasErrors = false;\n } catch (err) {\n message = `Failed to clear ${cacheDescription}: ${(err as Error).message || err}`;\n hasErrors = true;\n }\n\n await exit({\n exitCode: hasErrors ? 1 : 0,\n message,\n });\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,IAAI,EAAE,eAelB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const init = (command, createAction) => {
|
|
2
|
+
const cacheCommand = command
|
|
3
|
+
.command('cache')
|
|
4
|
+
.description('Operations related to the Cloudpack cache (requires a sub-command).')
|
|
5
|
+
.usage('<command>');
|
|
6
|
+
cacheCommand
|
|
7
|
+
.command('clean')
|
|
8
|
+
.description('Clears the Cloudpack cache.')
|
|
9
|
+
.alias('clear')
|
|
10
|
+
.action(createAction(() => ({
|
|
11
|
+
execute: import('./clean.js'),
|
|
12
|
+
})));
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/cache/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE;IAC7D,MAAM,YAAY,GAAG,OAAO;SACzB,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,qEAAqE,CAAC;SAClF,KAAK,CAAC,WAAW,CAAC,CAAC;IAEtB,YAAY;SACT,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,6BAA6B,CAAC;SAC1C,KAAK,CAAC,OAAO,CAAC;SACd,MAAM,CACL,YAAY,CAAC,GAAG,EAAE,CAAC,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC;KAC9B,CAAC,CAAC,CACJ,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { CommandFunction } from '../../types/CommandFunction.js';\n\nexport const init: CommandFunction = (command, createAction) => {\n const cacheCommand = command\n .command('cache')\n .description('Operations related to the Cloudpack cache (requires a sub-command).')\n .usage('<command>');\n\n cacheCommand\n .command('clean')\n .description('Clears the Cloudpack cache.')\n .alias('clear')\n .action(\n createAction(() => ({\n execute: import('./clean.js'),\n })),\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRoutes.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/createRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AACxF,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,kCAAkC,CAAC;AAKnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,GAAG,EACH,OAAO,EACP,UAAU,EACV,YAAY,EACZ,SAAS,EACT,MAAM,EACN,QAAQ,GACT,EAAE;IACD,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,uBAAuB,CAAC;CACnC,
|
|
1
|
+
{"version":3,"file":"createRoutes.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/createRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AACxF,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,kCAAkC,CAAC;AAKnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,GAAG,EACH,OAAO,EACP,UAAU,EACV,YAAY,EACZ,SAAS,EACT,MAAM,EACN,QAAQ,GACT,EAAE;IACD,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,uBAAuB,CAAC;CACnC,QAqEA"}
|
|
@@ -42,13 +42,13 @@ export function createRoutes({ app, url, session, definition, bundleServer, apiS
|
|
|
42
42
|
const entryScript =
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
44
44
|
route.exportEntry && importMap.imports[slash(path.join(definition.name, route.exportEntry))];
|
|
45
|
-
// Set the
|
|
45
|
+
// Set the appropriate Cloudpack headers/cookies in the response.
|
|
46
46
|
// TODO: setting the headers here prohibits cases where the page rendering is owned by existing server code
|
|
47
47
|
// that can only accept changing the scripts. We should consider moving to a model where an initial script
|
|
48
48
|
// fetch loads the import map and sets Cloudpack settings in local storage rather than headers/cookies.
|
|
49
49
|
setHeaders({ res, session, apiServer, bundleServer });
|
|
50
50
|
const inlineScripts = await getInlineScripts();
|
|
51
|
-
const {
|
|
51
|
+
const { content, statusCode, contentType } = await getHtmlResponse({
|
|
52
52
|
route,
|
|
53
53
|
baseUrl: url,
|
|
54
54
|
importMap,
|
|
@@ -60,8 +60,7 @@ export function createRoutes({ app, url, session, definition, bundleServer, apiS
|
|
|
60
60
|
req,
|
|
61
61
|
res,
|
|
62
62
|
});
|
|
63
|
-
|
|
64
|
-
res.status(statusCode).send(html).end();
|
|
63
|
+
res.type(contentType).status(statusCode).send(content).end();
|
|
65
64
|
log(`App server: Request: ${requestPath}, ext: ${requestExt}`);
|
|
66
65
|
})().catch((err) => {
|
|
67
66
|
console.error(err?.stack || err);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRoutes.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/createRoutes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,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AAE,CAAC,CAAC;gBACjE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;oBACjB,OAAO,CAAC,KAAK,CAAE,GAAa,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;oBAC5C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;KACF;AACH,CAAC","sourcesContent":["import type { PackageDefinitionsCache, PackageJson } from '@ms-cloudpack/bundler-types';\nimport type { Express, Request, Response } from '@ms-cloudpack/create-express-app';\nimport { express } from '@ms-cloudpack/create-express-app';\nimport { createImportMap } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport path from 'path';\nimport type { BundleServer } from '../../../types/BundleServer.js';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\nimport { getHtmlResponse } from './getHtmlResponse.js';\nimport { getInlineScripts } from './inlineScripts/getInlineScripts.js';\nimport { handleSessionVersion } from './handleSessionVersion.js';\nimport { log } from './log.js';\nimport { setHeaders } from './setHeaders.js';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\n\n/**\n * Creates the routes for the express app, considering how the config is defined.\n */\nexport function createRoutes({\n app,\n url,\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n packages,\n}: {\n app: Express;\n url: string;\n session: Session;\n definition: PackageJson;\n bundleServer: BundleServer;\n apiServer: ApiServer;\n config: CloudpackConfig;\n packages: PackageDefinitionsCache;\n}) {\n const routes = [...(config.devServer?.routes || [])];\n const hasDefaultRoute = routes.some((route) => route.match === '*' || route.match === '/');\n\n if (!hasDefaultRoute) {\n routes.push({\n match: '*',\n exportEntry: '.',\n });\n }\n\n for (const route of routes) {\n if (route.staticPath) {\n app.use(route.match, express.static(path.resolve(session.appPath, route.staticPath)));\n } else {\n app.get(route.match, (req: Request, res: Response) => {\n (async () => {\n // Build the import map if it hasn't been built yet for this session version.\n const sessionVersion = handleSessionVersion(session, req);\n const importMap =\n session.getImportMap() ||\n session.setImportMap(\n await createImportMap(\n {\n resolveMap: session.resolveMap,\n bundleServerUrl: bundleServer.url,\n sessionVersion,\n targetVersions: session.targetVersions,\n },\n { packages },\n ),\n );\n\n // Parse the request path, extension, grab the overlay script path.\n const requestPath = slash(req.path.substring(1));\n const requestExt = path.extname(requestPath);\n const overlayScript = importMap.imports['@ms-cloudpack/overlay'];\n const entryScript =\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n route.exportEntry && importMap.imports[slash(path.join(definition.name!, route.exportEntry))];\n // Set the appropriate Cloudpack headers/cookies in the response.\n // TODO: setting the headers here prohibits cases where the page rendering is owned by existing server code\n // that can only accept changing the scripts. We should consider moving to a model where an initial script\n // fetch loads the import map and sets Cloudpack settings in local storage rather than headers/cookies.\n setHeaders({ res, session, apiServer, bundleServer });\n const inlineScripts = await getInlineScripts();\n const { content, statusCode, contentType } = await getHtmlResponse({\n route,\n baseUrl: url,\n importMap,\n overlayScript,\n entryScript,\n session,\n definition,\n inlineScripts,\n req,\n res,\n });\n\n res.type(contentType).status(statusCode).send(content).end();\n\n log(`App server: Request: ${requestPath}, ext: ${requestExt}`);\n })().catch((err) => {\n console.error((err as Error)?.stack || err);\n res.status(500).send(`Error loading app: ${err}`);\n });\n });\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { CreateHtmlResult,
|
|
1
|
+
import type { CreateHtmlResult, CreateHtmlOptions } from '@ms-cloudpack/api-server';
|
|
2
2
|
/**
|
|
3
3
|
* Get the HTML response for the given route. If the route has a custom render script, use that.
|
|
4
4
|
*/
|
|
5
|
-
export declare function getHtmlResponse(options: CreateHtmlOptions): Promise<Exclude<CreateHtmlResult, string
|
|
5
|
+
export declare function getHtmlResponse(options: CreateHtmlOptions): Promise<Required<Exclude<CreateHtmlResult, string>>>;
|
|
6
6
|
//# sourceMappingURL=getHtmlResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHtmlResponse.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getHtmlResponse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"getHtmlResponse.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getHtmlResponse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAKlC;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC,CAwFtD"}
|
|
@@ -3,10 +3,6 @@ import { pathToFileURL } from 'url';
|
|
|
3
3
|
import { getDefaultHtmlResponse } from './getDefaultHtmlResponse.js';
|
|
4
4
|
import { JSDOM } from 'jsdom';
|
|
5
5
|
import fsPromises from 'fs/promises';
|
|
6
|
-
function isCustomHtmlResult(result) {
|
|
7
|
-
const customResult = result;
|
|
8
|
-
return (customResult.type === 'static-html' || customResult.type === 'js') && !!customResult.content;
|
|
9
|
-
}
|
|
10
6
|
/**
|
|
11
7
|
* Get the HTML response for the given route. If the route has a custom render script, use that.
|
|
12
8
|
*/
|
|
@@ -43,24 +39,22 @@ export async function getHtmlResponse(options) {
|
|
|
43
39
|
console.error(`The render script at "${renderScriptPath}" does not export a default function.`);
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
|
-
let
|
|
47
|
-
let
|
|
42
|
+
let content;
|
|
43
|
+
let contentType = 'html';
|
|
48
44
|
let statusCode = 200;
|
|
49
|
-
const
|
|
50
|
-
if (typeof
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
else if (isCustomHtmlResult(htmlResult)) {
|
|
54
|
-
html = htmlResult.content;
|
|
55
|
-
resultType = htmlResult.type;
|
|
45
|
+
const result = await createHtml(options);
|
|
46
|
+
if (typeof result === 'string') {
|
|
47
|
+
content = result;
|
|
56
48
|
}
|
|
57
49
|
else {
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
content = result.content;
|
|
51
|
+
contentType = result.contentType ?? contentType;
|
|
52
|
+
statusCode = result.statusCode ?? statusCode;
|
|
60
53
|
}
|
|
61
|
-
|
|
54
|
+
// endsWith('html') covers: 'html', '.html', and 'text/html'
|
|
55
|
+
if (contentType.endsWith('html')) {
|
|
62
56
|
try {
|
|
63
|
-
const htmlDocument = new JSDOM(
|
|
57
|
+
const htmlDocument = new JSDOM(content);
|
|
64
58
|
const { document } = htmlDocument.window;
|
|
65
59
|
// inject the import map.
|
|
66
60
|
if (entryScript || overlayScript) {
|
|
@@ -79,15 +73,16 @@ export async function getHtmlResponse(options) {
|
|
|
79
73
|
addScript(document.head, overlayScript);
|
|
80
74
|
// inject the entry script.
|
|
81
75
|
addScript(document.head, entryScript);
|
|
82
|
-
|
|
76
|
+
content = htmlDocument.serialize();
|
|
83
77
|
}
|
|
84
78
|
catch (e) {
|
|
85
79
|
console.error(`Error parsing html response for rendering route "${route.match}"`, e);
|
|
86
80
|
}
|
|
87
81
|
}
|
|
88
82
|
return {
|
|
89
|
-
|
|
83
|
+
content,
|
|
90
84
|
statusCode,
|
|
85
|
+
contentType,
|
|
91
86
|
};
|
|
92
87
|
}
|
|
93
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHtmlResponse.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getHtmlResponse.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"getHtmlResponse.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/getHtmlResponse.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,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OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;QAE3E,IAAI;YACF,IAAI,GAAG,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;SAC5D;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,+BAA+B,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC;SAC/D;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import path from 'path';\nimport { pathToFileURL } from 'url';\nimport type {\n CreateHtmlScript,\n CreateHtmlFunction,\n CreateHtmlResult,\n CreateHtmlOptions,\n} from '@ms-cloudpack/api-server';\nimport { getDefaultHtmlResponse } from './getDefaultHtmlResponse.js';\nimport { JSDOM } from 'jsdom';\nimport fsPromises from 'fs/promises';\n\n/**\n * Get the HTML response for the given route. If the route has a custom render script, use that.\n */\nexport async function getHtmlResponse(\n options: CreateHtmlOptions,\n): Promise<Required<Exclude<CreateHtmlResult, string>>> {\n const { route, session, overlayScript, entryScript, inlineScripts } = options;\n let createHtml: CreateHtmlFunction = getDefaultHtmlResponse;\n\n if (route.renderScript) {\n const renderScriptPath = path.resolve(session.appPath, route.renderScript);\n let cacheBreakerQueryParam = `?t=${Date.now()}`;\n\n try {\n const { mtime } = await fsPromises.stat(path.resolve(session.appPath, route.renderScript));\n\n cacheBreakerQueryParam = `?t=${mtime.getTime()}`;\n } catch {\n /* no-op */\n }\n\n if (isHtml(renderScriptPath)) {\n createHtml = readStaticHtml;\n } else {\n // Get the html factory function from a script default export.\n const renderScriptUrl = pathToFileURL(renderScriptPath).toString();\n\n // Note: because there isn't a way to purge the require cache, we need to add a cache breaker query param to the\n // script path to ensure we get the latest version of the script. This could be improved by using the git hash of\n // the file if it exists, or a hash of the content, or even the timestamp of the file.\n try {\n createHtml = ((await import(renderScriptUrl + cacheBreakerQueryParam)) as CreateHtmlScript).default;\n } catch (e) {\n console.error(`Error importing render script at \"${renderScriptUrl}\":`, e);\n }\n }\n\n if (!createHtml) {\n console.error(`The render script at \"${renderScriptPath}\" does not export a default function.`);\n }\n }\n\n let content;\n let contentType = 'html';\n let statusCode = 200;\n\n const result = await createHtml(options);\n if (typeof result === 'string') {\n content = result;\n } else {\n content = result.content;\n contentType = result.contentType ?? contentType;\n statusCode = result.statusCode ?? statusCode;\n }\n\n // endsWith('html') covers: 'html', '.html', and 'text/html'\n if (contentType.endsWith('html')) {\n try {\n const htmlDocument = new JSDOM(content);\n const { document } = htmlDocument.window;\n\n // inject the import map.\n if (entryScript || overlayScript) {\n const script = document.createElement('script');\n script.type = 'importmap';\n script.innerHTML = JSON.stringify(session.getImportMap(), null, 2);\n document.head.prepend(script);\n }\n\n for (const inlineScript of inlineScripts) {\n const script = document.createElement('script');\n script.type = 'module';\n script.innerHTML = inlineScript;\n document.head.appendChild(script);\n }\n\n // inject the overlay script.\n addScript(document.head, overlayScript);\n\n // inject the entry script.\n addScript(document.head, entryScript);\n\n content = htmlDocument.serialize();\n } catch (e) {\n console.error(`Error parsing html response for rendering route \"${route.match}\"`, e);\n }\n }\n\n return {\n content,\n statusCode,\n contentType,\n };\n}\n\n/**\n * Helper function to add a script to the document.\n */\nfunction addScript(parentElement: HTMLElement, url: string | undefined) {\n if (url) {\n const script = parentElement.ownerDocument.createElement('script');\n\n script.type = 'module';\n script.src = url;\n parentElement.appendChild(script);\n }\n}\n\nfunction isHtml(scriptPath: string): boolean {\n // path has an .htm or .html extension; case insensitive.\n return scriptPath.toLowerCase().match(/\\.htm(l)?$/) !== null;\n}\n\nasync function readStaticHtml(options: CreateHtmlOptions): Promise<string> {\n const { route } = options;\n let html = '';\n\n if (route.renderScript) {\n const htmlPath = path.resolve(options.session.appPath, route.renderScript);\n\n try {\n html = (await fsPromises.readFile(htmlPath, 'utf8')) || '';\n } catch (e) {\n console.error(`Error reading HTML file at \"${htmlPath}\".`, e);\n }\n }\n\n return html;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setHeaders.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/setHeaders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE;IACjC,GAAG,EAAE,QAAQ,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;CAC5B,
|
|
1
|
+
{"version":3,"file":"setHeaders.d.ts","sourceRoot":"","sources":["../../../../src/commands/start/appServer/setHeaders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE;IACjC,GAAG,EAAE,QAAQ,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;CAC5B,QAWA"}
|
|
@@ -4,7 +4,6 @@ import { cookieNames, getCloudpackSessionVersionCookie } from './cookieNames.js'
|
|
|
4
4
|
*/
|
|
5
5
|
export function setHeaders(params) {
|
|
6
6
|
const { res, session, apiServer, bundleServer } = params;
|
|
7
|
-
res.header('Content-Type', 'text/html');
|
|
8
7
|
res.header('Cache-Control', 'no-cache');
|
|
9
8
|
res.header('Access-Control-Allow-Origin', '*');
|
|
10
9
|
res.cookie(cookieNames.sessionId, session.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setHeaders.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/setHeaders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AAEjF;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAK1B;IACC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAEzD,GAAG,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"setHeaders.js","sourceRoot":"","sources":["../../../../src/commands/start/appServer/setHeaders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAC;AAEjF;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAK1B;IACC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAEzD,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IACxC,GAAG,CAAC,MAAM,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAC;IAE/C,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IAC9C,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1D,GAAG,CAAC,MAAM,CAAC,gCAAgC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC/F,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9C,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["import type { Response } from '@ms-cloudpack/create-express-app';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\nimport type { BundleServer } from '../../../types/BundleServer.js';\nimport { cookieNames, getCloudpackSessionVersionCookie } from './cookieNames.js';\n\n/**\n * Set the Cloudpack headers and cookies in the response.\n */\nexport function setHeaders(params: {\n res: Response;\n session: Session;\n apiServer: ApiServer;\n bundleServer: BundleServer;\n}) {\n const { res, session, apiServer, bundleServer } = params;\n\n res.header('Cache-Control', 'no-cache');\n res.header('Access-Control-Allow-Origin', '*');\n\n res.cookie(cookieNames.sessionId, session.id);\n res.cookie(cookieNames.sessionSequence, session.sequence);\n res.cookie(getCloudpackSessionVersionCookie(session.projectName), session.getSessionVersion());\n res.cookie(cookieNames.apiUrl, apiServer.url);\n res.cookie(cookieNames.bundleServerUrl, bundleServer.url);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { pathExists } from 'fs-extra';
|
|
2
1
|
import { findCloudpackAppPaths } from '../../common/findCloudpackAppPaths.js';
|
|
2
|
+
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { createPathToChoiceMap } from './createPathToChoiceMap.js';
|
|
5
5
|
import { getAppPathFromUser } from './getAppPathFromUser.js';
|
|
@@ -12,7 +12,7 @@ import { getAppPathFromUser } from './getAppPathFromUser.js';
|
|
|
12
12
|
* @returns The app path of the app that Cloudpack should start
|
|
13
13
|
*/
|
|
14
14
|
export async function getStartingAppPath(cwd, desiredApp) {
|
|
15
|
-
const cwdIsCloudpackApp =
|
|
15
|
+
const cwdIsCloudpackApp = fs.existsSync(path.resolve(path.join(cwd, 'cloudpack.config.json')));
|
|
16
16
|
if (cwdIsCloudpackApp) {
|
|
17
17
|
return cwd;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStartingAppPath.js","sourceRoot":"","sources":["../../../src/commands/start/getStartingAppPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"getStartingAppPath.js","sourceRoot":"","sources":["../../../src/commands/start/getStartingAppPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAAW,EAAE,UAAmB;IACvE,MAAM,iBAAiB,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAC/F,IAAI,iBAAiB,EAAE;QACrB,OAAO,GAAG,CAAC;KACZ;IAED,MAAM,WAAW,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,OAAO,GAAG,CAAC;KACZ;SAAM,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QACnC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;KACvB;SAAM;QACL,MAAM,wBAAwB,GAAG,MAAM,qBAAqB,CAAC,WAAW,CAAC,CAAC;QAC1E,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;QAC/E,OAAO,OAAO,IAAI,GAAG,CAAC;KACvB;AACH,CAAC","sourcesContent":["import { findCloudpackAppPaths } from '../../common/findCloudpackAppPaths.js';\nimport fs from 'fs';\nimport path from 'path';\nimport { createPathToChoiceMap } from './createPathToChoiceMap.js';\nimport { getAppPathFromUser } from './getAppPathFromUser.js';\n\n/**\n * Gets the appPath from which Cloudpack will start. If the CWD is a Cloudpack-enabled app,\n * we'll start there; otherwise, we'll scan for Cloudpack-enabled app and present the user\n * with a menu. If no app are found, Cloudpack will just try to start the CWD anyway.\n * @param cwd - The current working directory to start in when finding the starting app path\n * @param desiredApp - The app that should be started as specified via --app arg\n * @returns The app path of the app that Cloudpack should start\n */\nexport async function getStartingAppPath(cwd: string, desiredApp?: string) {\n const cwdIsCloudpackApp = fs.existsSync(path.resolve(path.join(cwd, 'cloudpack.config.json')));\n if (cwdIsCloudpackApp) {\n return cwd;\n }\n\n const folderPaths = findCloudpackAppPaths(cwd);\n if (folderPaths.length === 0) {\n return cwd;\n } else if (folderPaths.length === 1) {\n return folderPaths[0];\n } else {\n const pathToCloudpackConfigMap = await createPathToChoiceMap(folderPaths);\n const appPath = await getAppPathFromUser(pathToCloudpackConfigMap, desiredApp);\n return appPath ?? cwd;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.1",
|
|
4
4
|
"description": "The Cloudpack command line interface - a tool for managing fast inner and outer looping in web apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@lage-run/target-graph": "^0.8.7",
|
|
14
|
-
"@ms-cloudpack/api-server": "^0.
|
|
15
|
-
"@ms-cloudpack/config": "^0.
|
|
14
|
+
"@ms-cloudpack/api-server": "^0.21.1",
|
|
15
|
+
"@ms-cloudpack/config": "^0.13.0",
|
|
16
16
|
"@ms-cloudpack/create-express-app": "^1.3.11",
|
|
17
17
|
"@ms-cloudpack/json-utilities": "^0.0.7",
|
|
18
|
-
"@ms-cloudpack/overlay": "^0.16.
|
|
18
|
+
"@ms-cloudpack/overlay": "^0.16.3",
|
|
19
19
|
"@ms-cloudpack/package-utilities": "^5.1.9",
|
|
20
20
|
"@ms-cloudpack/path-string-parsing": "^1.1.0",
|
|
21
21
|
"@ms-cloudpack/path-utilities": "^2.3.4",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"commander": "^11.0.0",
|
|
25
25
|
"cross-spawn": "^7.0.3",
|
|
26
26
|
"fast-glob": "^3.2.12",
|
|
27
|
-
"fs-extra": "^11.0.0",
|
|
28
27
|
"glob-hasher": "^1.2.1",
|
|
29
28
|
"jsdom": "^22.0.0",
|
|
30
29
|
"open": "^9.0.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEtE,eAAO,MAAM,IAAI,EAAE,eAKlB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/dashboard/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,IAAI,GAAoB,CAAC,OAAO,EAAE,EAAE;IAC/C,OAAO;SACJ,OAAO,CAAC,WAAW,CAAC;SACpB,WAAW,CAAC,sBAAsB,CAAC;SACnC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC","sourcesContent":["import type { CommandFunction } from '../../types/CommandFunction.js';\n\nexport const init: CommandFunction = (command) => {\n command\n .command('dashboard')\n .description('Shows the dashboard.')\n .action(() => console.log('i am showing the dashboard.'));\n};\n"]}
|
|
File without changes
|