@jpmorganchase/mosaic-cli 0.0.0-snapshot-20240604074928
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/dist/chunk-4TC6JS4B.mjs +1 -0
- package/dist/chunk-FCNWFPGR.mjs +1 -0
- package/dist/chunk-IHS5R2XF.mjs +1 -0
- package/dist/chunk-IMOZUZOL.mjs +1 -0
- package/dist/chunk-NA262GTT.mjs +1 -0
- package/dist/chunk-ON3CEV4U.mjs +1 -0
- package/dist/chunk-WOFOIVOG.mjs +1 -0
- package/dist/chunk-YKBK5I4U.mjs +1 -0
- package/dist/exportStatic.d.ts +1 -0
- package/dist/exportStatic.mjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/plugins/createMosaicInstance.d.ts +3 -0
- package/dist/plugins/createMosaicInstance.mjs +1 -0
- package/dist/plugins/mosaicAdminPlugin.d.ts +15 -0
- package/dist/plugins/mosaicAdminPlugin.mjs +1 -0
- package/dist/plugins/mosaicFastifyPlugin.d.ts +21 -0
- package/dist/plugins/mosaicFastifyPlugin.mjs +1 -0
- package/dist/plugins/mosaicWorkflowsPlugin.d.ts +18 -0
- package/dist/plugins/mosaicWorkflowsPlugin.mjs +1 -0
- package/dist/serve.d.ts +5 -0
- package/dist/serve.mjs +1 -0
- package/dist/serveStatic.d.ts +2 -0
- package/dist/serveStatic.mjs +2 -0
- package/dist/vercel-snapshot.d.ts +10 -0
- package/dist/vercel-snapshot.mjs +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawn as s}from"child_process";function n(o){let r=s(o,{cwd:process.cwd(),shell:!0});return r.stdout.on("data",t=>console.log(t.toString())),r.stderr.on("data",t=>console.error(t.toString())),r}async function c(){try{let o=n("yarn serve:fs");n("yarn build:static").on("close",()=>o.kill())}catch(o){console.error(o),process.exit(1)}}export{c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import i from"@jpmorganchase/mosaic-core";async function c(a){let o=new i(a);return await o.start(),o}export{c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"path";import{globby as h}from"globby";import o from"fs-extra";async function g(r,a){let{mode:p,platform:c}=r.deployment;if(p==="snapshot-file"&&c==="vercel"){console.info("[Mosaic] deployment platform is vercel...adding snapshot files to site output trace");let s=process.cwd(),i=e.posix.join(s,".next"),l=a.out;o.existsSync(i)||console.warn("[Mosaic] unable to update nextjs trace file. Build the site before generating the snapshot");let t=e.posix.join(i,"server","pages","[...route].js.nft.json"),f=await h(`**/${l}/**`,{cwd:s,onlyFiles:!0}),n=JSON.parse(await o.promises.readFile(t,"utf-8"));f.forEach(d=>{let m=e.posix.dirname(t),u=e.posix.relative(m,e.posix.resolve(d));n.files.push(u)}),await o.promises.writeFile(t,JSON.stringify(n))}}export{g as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import p from"fastify-plugin";import a from"path";async function l(n,f){let{config:r,scope:c,mosaic:o}=f,i=Array.isArray(c)?o.filesystem.scope(c):o.filesystem;n.decorate("mosaic",{config:r,core:o,fs:i}),n.get("/*",async(t,s)=>{try{if(await i.promises.exists(t.url))if((await i.promises.stat(t.url)).isDirectory())await i.promises.exists(a.join(t.url,"index"))?(s.header("Content-Type","application/json"),s.status(302).send({redirect:a.join(t.url,"index")})):s.status(404);else{let e=String(await i.promises.realpath(t.url));a.extname(e)===".mdx"?s.header("Content-Type","text/mdx"):a.extname(e)===".json"?s.header("Content-Type","application/json"):a.extname(e)===".xml"&&s.header("Content-Type","application/xml");let m=await i.promises.readFile(t.url);s.send(m)}else s.status(404)}catch(e){console.error(e),s.status(500)}})}var d=p(l,{fastify:"4.x",name:"fastify-mosaic"});export{d as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import m from"fastify-plugin";function h(a,f,l){let{prefix:r}=f,{config:p,fs:y,core:u}=a.mosaic;a.get(`/${r}/config`,async(i,e)=>{e.header("Content-Type","application/json");let s=p.sources.map(t=>{let n=t?.options,c=n?.credentials;if(c&&t.modulePath==="@jpmorganchase/mosaic-source-git-repo"){let d=c.split(":")||[];d.length>0&&(t.options={...n,credentials:`${d[0]}: ********`})}return t}),o={...p,sources:s};e.send(o)}),a.get(`/${r}/content/dump`,(i,e)=>{e.header("Content-Type","application/json"),e.send(y.toJSON())}),a.get(`/${r}/sources/list`,async(i,e)=>{e.header("Content-Type","application/json");let o=(await u.listSources()).map(t=>{let n=p.sources[t.index],c=n?.options;if(c?.credentials&&n.modulePath==="@jpmorganchase/mosaic-source-git-repo"){let d=c.credentials?.split(":")||[];d.length>0&&(n.options={...c,credentials:`${d[0]}: ********`})}return{name:t.name,...n,pluginErrors:t.pluginErrors}});e.send(o)}),a.put(`/${r}/source/stop`,async(i,e)=>{e.header("Content-Type","application/text");let{name:s}=i.body;if(s)try{await u.stopSource(String(s)),e.send(`${s} stopped successfully.`)}catch(o){console.error(o),e.status(500).send(`${s} not stopped. Check you have the right name!`)}else e.status(500).send("No source name provided.")}),a.put(`/${r}/source/restart`,async(i,e)=>{e.header("Content-Type","application/text");let{name:s}=i.body;if(s)try{await u.restartSource(String(s)),e.send(`${s} restarted successfully.`)}catch(o){console.error(o),e.status(500).send(`${s} not restarted. Check you have the right name!`)}else e.status(500).send("No source name provided.")}),a.post(`/${r}/source/add`,async(i,e)=>{try{let{definition:s,isPreview:o=!0}=i.body;if(e.header("Content-Type","application/text"),!f.enableSourcePush)throw new Error("Source push is disabled.");if(!s)throw new Error("Source definition is required");if(o){let n=`preview-${s.namespace}`;s.namespace=n}let t=await u.addSource(s);e.send(t!==void 0?`Source ${t.id.description} added successfully`:"Unable to add source")}catch(s){console.error(s),e.status(500).send(s.message)}}),l()}var F=m(h,{fastify:"4.x",name:"fastify-mosaic-admin",dependencies:["fastify-mosaic"]});export{F as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./chunk-WOFOIVOG.mjs";import{a as c}from"./chunk-FCNWFPGR.mjs";import{a as s}from"./chunk-NA262GTT.mjs";import{a}from"./chunk-IMOZUZOL.mjs";import f from"fastify";import p from"cors";import g from"@fastify/middie";var l="_mosaic_",r=f({logger:!1,pluginTimeout:2e4});async function u(o,t,i){let m=await c(o);await r.register(g),await r.register(a,{config:o,scope:i,mosaic:m}),await r.register(e),await r.register(s,{prefix:l,enableSourcePush:o.enableSourcePush}),r.use(p()),await(async()=>{try{await r.listen({port:t}),console.log(`[Mosaic] Listening on port ${t}${Array.isArray(i)?` (scoped to ${i.join(", ")})`:""}`)}catch(n){r.log.error(n),process.exit(1)}})()}export{r as a,u as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import w from"fastify-plugin";import k from"path";import d from"md5";import l from"@fastify/websocket";async function y(r,R){await r.register(l);let{fs:t,core:c}=r.mosaic;r.get("/workflows",{websocket:!0},s=>{s.socket.on("message",async g=>{if(s.socket.OPEN)try{let{type:m,route:e,name:o,user:a,...p}=JSON.parse(g.toString());o||s.socket.send(JSON.stringify({status:"ERROR",message:"Workflow name is required"})),a||s.socket.send(JSON.stringify({status:"ERROR",message:"Workflow must be run for a user"}));let u=d(`${a.sid.toLowerCase()} - ${o.toLowerCase()}`),i=(n,f)=>s.socket.send(JSON.stringify({status:f,message:n,channel:u}));if(await t.promises.exists(e)){let n=(await t.promises.stat(e)).isDirectory()?k.posix.join(e,"index"):e,f=await t.promises.realpath(n);c.triggerWorkflow(i,o,f,{user:a,...p}),i(`Workflow ${o} has started`,"SUCCESS")}else i(`${e} not found`,"ERROR")}catch(m){console.error(m),s.socket.send(JSON.stringify({status:"ERROR",message:"e.message"}))}})})}var x=w(y,{fastify:"4.x",name:"fastify-mosaic-workflows",dependencies:["fastify-mosaic"]});export{x as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import a from"fastify";import n from"@fastify/static";async function c(o,e){let s=async()=>{try{await t.listen({port:e}),console.log(`[Mosaic] Listening on port ${e}`)}catch(r){t.log.error(r),process.exit(1)}},t=a();await t.register(n,{root:o}),t.setNotFoundHandler((r,i)=>{i.sendFile("404.html")}),await s()}export{c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function exportStatic(): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-4TC6JS4B.mjs";export{a as default};
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as i}from"./chunk-4TC6JS4B.mjs";import{b as s}from"./chunk-ON3CEV4U.mjs";import"./chunk-WOFOIVOG.mjs";import{a as p}from"./chunk-YKBK5I4U.mjs";import{a as n}from"./chunk-IHS5R2XF.mjs";import"./chunk-FCNWFPGR.mjs";import"./chunk-NA262GTT.mjs";import"./chunk-IMOZUZOL.mjs";import{program as r}from"commander";import t from"path";import{pathToFileURL as c}from"url";r.option("-c, --config <string>","Config path").option("-o, --out <string>","Output directory",".tmp/.mosaic-build").option("-s, --scope <strings>","Command separated namespaces").option("-p, --port <number>","Port to serve on","8080");r.parse();var o=r.opts();if(r.args[0]==="export:static")i();else if(r.args[0]==="serve:static")p(t.resolve(process.cwd(),o.out),o.port);else{let e;if(o.config!==void 0){if(e=await import(c(t.resolve(process.cwd(),o.config)).toString()),!e)throw new Error(`[Mosaic] could not find config file at ${t.resolve(process.cwd(),o.config)}.`)}else throw new Error("[Mosaic] no config file provided");r.args[0]==="serve"?s(e.default,o.port,o.scope&&o.scope.split(",")):r.args[0]==="deploy"&&n(e.default,o)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-FCNWFPGR.mjs";export{a as createMosaicInstance};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
export interface FastifyMosaicAdminPluginOptions {
|
|
3
|
+
prefix: string;
|
|
4
|
+
enableSourcePush?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface AdminRequestBodyType {
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
declare function mosaicAdmin(fastify: FastifyInstance, options: FastifyMosaicAdminPluginOptions, next: any): void;
|
|
10
|
+
/**
|
|
11
|
+
* Fastify plugin that adds support for the Mosaic Admin API routes
|
|
12
|
+
* https://mosaic-mosaic-dev-team.vercel.app/mosaic/configure/admin/index
|
|
13
|
+
*/
|
|
14
|
+
declare const _default: typeof mosaicAdmin;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-NA262GTT.mjs";export{a as default};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
import MosaicCore from '@jpmorganchase/mosaic-core';
|
|
3
|
+
import { MosaicConfig, IUnionVolume } from '@jpmorganchase/mosaic-types';
|
|
4
|
+
export interface FastifyMosaicPluginOptions {
|
|
5
|
+
config: MosaicConfig;
|
|
6
|
+
scope?: string[];
|
|
7
|
+
mosaic: MosaicCore;
|
|
8
|
+
}
|
|
9
|
+
export interface FastifyMosaic {
|
|
10
|
+
config: MosaicConfig;
|
|
11
|
+
core: MosaicCore;
|
|
12
|
+
fs: IUnionVolume;
|
|
13
|
+
}
|
|
14
|
+
declare function fastifyMosaic(fastify: FastifyInstance, options: FastifyMosaicPluginOptions): Promise<void>;
|
|
15
|
+
declare module 'fastify' {
|
|
16
|
+
interface FastifyInstance {
|
|
17
|
+
mosaic: FastifyMosaic;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
declare const _default: typeof fastifyMosaic;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-IMOZUZOL.mjs";export{a as default};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
export interface FastifyMosaicAdminPluginOptions {
|
|
3
|
+
prefix?: string;
|
|
4
|
+
enableSourcePush?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface WorkflowRequestBodyType {
|
|
7
|
+
user: string;
|
|
8
|
+
route: string;
|
|
9
|
+
markdown: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
declare function mosaicWorkflows(fastify: FastifyInstance, _options: any): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Fastify plugin that adds support for the Mosaic Workflows
|
|
15
|
+
* https://mosaic-mosaic-dev-team.vercel.app/mosaic/configure/admin/index
|
|
16
|
+
*/
|
|
17
|
+
declare const _default: typeof mosaicWorkflows;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-WOFOIVOG.mjs";export{a as default};
|
package/dist/serve.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import Fastify from 'fastify';
|
|
3
|
+
import { MosaicConfig } from '@jpmorganchase/mosaic-types';
|
|
4
|
+
export declare const server: Fastify.FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault> & PromiseLike<Fastify.FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault>>;
|
|
5
|
+
export default function serve(config: MosaicConfig, port: number, scope?: string[]): Promise<void>;
|
package/dist/serve.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-ON3CEV4U.mjs";import"./chunk-WOFOIVOG.mjs";import"./chunk-FCNWFPGR.mjs";import"./chunk-NA262GTT.mjs";import"./chunk-IMOZUZOL.mjs";export{b as default,a as server};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When deploying a mosaic site to vercel, snapshot files are ignored resulting in a 404 when a page is accessed from the site.
|
|
3
|
+
*
|
|
4
|
+
* Vercel uses output file tracing (https://nextjs.org/docs/advanced-features/output-file-tracing) to determine what files need to be deployed.
|
|
5
|
+
* Due to the dynamic nature of mosaic sites, files that are required, the snapshots, are not traced correctly.
|
|
6
|
+
*
|
|
7
|
+
* This script adds an entry into the [...route].js.nft.json file for each file in the provided snapshot ensuring that the snapshot files are deployed.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare function updateTraceFile(config: any, options: any): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-IHS5R2XF.mjs";export{a as updateTraceFile};
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jpmorganchase/mosaic-cli",
|
|
3
|
+
"version": "0.0.0-snapshot-20240604074928",
|
|
4
|
+
"author": "",
|
|
5
|
+
"description": "Mosaic command line scripts",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"main": "./dist/index.mjs",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"node": "./dist/index.mjs",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=16.10.0 || >=18.0.0"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"mosaic": "./dist/index.mjs"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "npm-run-all --parallel build:*",
|
|
28
|
+
"build:types": "tsc",
|
|
29
|
+
"build:cli": "node ./scripts/bundle.mjs",
|
|
30
|
+
"clean": "rm -fr dist",
|
|
31
|
+
"docker:build": "docker build . --tag mosaic-fs:latest",
|
|
32
|
+
"docker:start": "docker run -it --rm --ipc=host -p 8080:8080 --mount source=docs,destination=/app/docs --network mosaic-net --name mosaic-fs mosaic-fs:latest",
|
|
33
|
+
"lint": "eslint --ignore-pattern \"**/__tests__/**\""
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git@github.com:jpmorganchase/mosaic.git",
|
|
38
|
+
"directory": "packages/cli"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@jpmorganchase/mosaic-types": "0.0.0-snapshot-20240604074928",
|
|
42
|
+
"esbuild": "0.19.11",
|
|
43
|
+
"esbuild-node-externals": "^1.12.0",
|
|
44
|
+
"fast-glob": "^3.2.7",
|
|
45
|
+
"@types/ws": "^8.5.7"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@jpmorganchase/mosaic-core": "0.0.0-snapshot-20240604074928",
|
|
49
|
+
"@jpmorganchase/mosaic-plugins": "0.0.0-snapshot-20240604074928",
|
|
50
|
+
"@jpmorganchase/mosaic-standard-generator": "0.0.0-snapshot-20240604074928",
|
|
51
|
+
"@jpmorganchase/mosaic-source-local-folder": "0.0.0-snapshot-20240604074928",
|
|
52
|
+
"@aws-sdk/client-s3": "^3.359.0",
|
|
53
|
+
"@fastify/middie": "^8.3.0",
|
|
54
|
+
"@fastify/websocket": "^8.2.0",
|
|
55
|
+
"@fastify/static": "^6.11.2",
|
|
56
|
+
"commander": "^9.4.1",
|
|
57
|
+
"cors": "^2.8.5",
|
|
58
|
+
"deepmerge": "^4.2.2",
|
|
59
|
+
"fastify": "^4.23.2",
|
|
60
|
+
"fastify-plugin": "^4.5.1",
|
|
61
|
+
"fs-extra": "^10.1.0",
|
|
62
|
+
"globby": "^13.1.3",
|
|
63
|
+
"md5": "*",
|
|
64
|
+
"mkdirp": "^1.0.4"
|
|
65
|
+
}
|
|
66
|
+
}
|