@jpmorganchase/mosaic-cli 0.1.0-beta.8 → 0.1.0-beta.80
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/build.d.ts +1 -0
- package/dist/build.mjs +1 -0
- package/dist/chunk-6E5PQQKS.mjs +1 -0
- package/dist/chunk-DYNA3PMW.mjs +1 -0
- package/dist/chunk-FCNWFPGR.mjs +1 -0
- package/dist/chunk-HQMO6BLF.mjs +1 -0
- package/dist/chunk-IMOZUZOL.mjs +1 -0
- package/dist/chunk-ND7PMTGH.mjs +3 -0
- package/dist/chunk-P3RXN7HU.mjs +1 -0
- package/dist/chunk-VIYGD5XX.mjs +1 -0
- package/dist/chunk-Y6WPZ5AX.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/upload-s3-snapshot.d.ts +1 -0
- package/dist/upload-s3-snapshot.mjs +1 -0
- package/dist/vercel-snapshot.d.ts +10 -0
- package/dist/vercel-snapshot.mjs +1 -0
- package/package.json +42 -10
- package/CHANGELOG.md +0 -62
- package/dist/build.js +0 -92
- package/dist/index.js +0 -45
- package/dist/serve-snapshot.js +0 -86
- package/dist/serve.js +0 -76
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function build(config: any, targetDir: any, options: any): Promise<void>;
|
package/dist/build.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-ND7PMTGH.mjs";import"./chunk-DYNA3PMW.mjs";export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as g,c as p}from"./chunk-DYNA3PMW.mjs";import l from"fastify-plugin";import y from"path";import R from"md5";import S from"@fastify/websocket";async function O(r,W){await r.register(S);let{fs:t,core:u}=r.mosaic;r.get("/workflows",{websocket:!0},s=>{s.socket.on("message",async w=>{if(s.socket.OPEN)try{let m=JSON.parse(w.toString()),{type:c,route:e,name:o,user:a}=m,k=p(m,["type","route","name","user"]);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 d=R(`${a.sid.toLowerCase()} - ${o.toLowerCase()}`),i=(n,f)=>s.socket.send(JSON.stringify({status:f,message:n,channel:d}));if(await t.promises.exists(e)){let n=(await t.promises.stat(e)).isDirectory()?y.posix.join(e,"index"):e,f=await t.promises.realpath(n);u.triggerWorkflow(i,o,f,g({user:a},k)),i(`Workflow ${o} has started`,"SUCCESS")}else i(`${e} not found`,"ERROR")}catch(c){console.error(c),s.socket.send(JSON.stringify({status:"ERROR",message:"e.message"}))}})})}var P=l(O,{fastify:"4.x",name:"fastify-mosaic-workflows",dependencies:["fastify-mosaic"]});export{P as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty,j=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var e=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var f=(a,b,c)=>b in a?i(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c,l=(a,b)=>{for(var c in b||(b={}))g.call(b,c)&&f(a,c,b[c]);if(e)for(var c of e(b))h.call(b,c)&&f(a,c,b[c]);return a},m=(a,b)=>j(a,k(b));var n=(a,b)=>{var c={};for(var d in a)g.call(a,d)&&b.indexOf(d)<0&&(c[d]=a[d]);if(a!=null&&e)for(var d of e(a))b.indexOf(d)<0&&h.call(a,d)&&(c[d]=a[d]);return c};export{l as a,m as b,n as c};
|
|
@@ -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{a as e}from"./chunk-6E5PQQKS.mjs";import{a as c}from"./chunk-FCNWFPGR.mjs";import{a as s}from"./chunk-Y6WPZ5AX.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 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,3 @@
|
|
|
1
|
+
import{a as d,b as w}from"./chunk-DYNA3PMW.mjs";import n from"fs";import e from"path";import k from"deepmerge";import h from"fs-extra";import b from"@jpmorganchase/mosaic-core";async function F(r,y,u){r.plugins=r.plugins.filter(({runTimeOnly:i})=>!i),r.sources=r.sources.map(i=>w(d({},i),{options:w(d({},i.options),{cache:!1})}));let p=u.scope&&u.scope.split(","),l=new b(r),s=e.posix.join(y,u.name??new Date().toISOString());await h.emptyDir(s),await l.start();let f=Array.isArray(p)?l.filesystem.scope(p):l.filesystem,g=0;l.onSourceUpdate(async()=>{try{if(++g===r.sources.length){let i=f.symlinksToJSON(),S=await f.promises.glob("**",{cwd:"/",onlyFiles:!0});for(let t of S){let o=await f.promises.readFile(String(t),{includeConflicts:!0}),c=o[0];if(o.length>1)if(e.posix.extname(String(t))===".json"){console.warn(`'${t}' returned multiple files at the same location. Since the files were JSON dot files, they were merged using \`deepmerge\`.`);let a=o.map(m=>JSON.parse(String(m)));c=Buffer.from(JSON.stringify(k(a[0],a[1])))}else throw new Error(`'${t}' returned multiple files at the same location, this will result in overwritten data in the output. Aborting build.
|
|
2
|
+
|
|
3
|
+
Try using \`--scope\` to just output certain namespaced sources, or adding a \`prefixDir\` to the source options to move the source files into a separate folder.`);await n.promises.mkdir(e.dirname(e.join(s,String(t))),{recursive:!0}),await n.promises.writeFile(e.join(s,String(t)),c)}let x=process.cwd();for(let t in i)if(!t.startsWith("/.tags")){for(let{target:o}of i[t])if(!o.startsWith("/.tags")){await h.ensureDir(e.join(s,e.dirname(t)));try{!!await n.promises.stat(e.join(s,t))&&(console.error(new Error(`Symlink at '${e.join(s,t)}' already exists. Aborting build.`)),process.exit(1))}catch{let c=e.join(s,o),a=e.join(s,t),m=e.basename(a),j=e.relative(e.dirname(a),c);process.chdir(e.dirname(a)),n.existsSync(m)&&n.unlinkSync(m),await n.promises.symlink(j,m)}}}process.chdir(x),console.log(`[Mosaic] filesystem for ${Array.isArray(p)?p.length:r.sources.length} source(s) written to disk at '${s}'`),l.stop()}}catch(i){console.error(i),process.exit(1)}})}export{F as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{globby as _}from"globby";import m from"path";import E from"fs";import{S3Client as p,CreateBucketCommand as A,PutObjectCommand as I}from"@aws-sdk/client-s3";import s from"assert";function d(n,e,t){return new p({region:n,credentials:{accessKeyId:e,secretAccessKey:t}})}async function u(n){s(process.env.MOSAIC_S3_BUCKET,"Cannot read S3 bucket - MOSAIC_S3_BUCKET environment var is missing"),s(process.env.MOSAIC_S3_REGION,"Cannot read S3 bucket - MOSAIC_S3_REGION environment var is missing"),s(process.env.MOSAIC_S3_ACCESS_KEY_ID,"Cannot read S3 bucket - MOSAIC_S3_ACCESS_KEY_ID environment var is missing"),s(process.env.MOSAIC_S3_SECRET_ACCESS_KEY,"Cannot read S3 bucket - MOSAIC_S3_SECRET_ACCESS_KEY environment var is missing");let e=process.env.MOSAIC_S3_BUCKET,t=process.env.MOSAIC_S3_REGION,c=process.env.MOSAIC_S3_ACCESS_KEY_ID,C=process.env.MOSAIC_S3_SECRET_ACCESS_KEY,o=d(t,c,C);await o.send(new A({Bucket:e})),(await _(n)).forEach(async S=>{let r=S.replace(`${n}${m.sep}`,"");console.log(`Upload ${r} to bucket ${e}`);let a=await E.promises.readFile(S,{encoding:"utf-8"}),i=new I({Bucket:e,Key:r,Body:a});await o.send(i)})}export{u as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"path";import{globby as x}from"globby";import o from"fs-extra";async function j(r,s){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 i=process.cwd(),n=e.posix.join(i,".next"),l=s.out,f=s.name??new Date().toISOString();o.existsSync(n)||console.warn("[Mosaic] unable to update nextjs trace file. Build the site before generating the snapshot");let t=e.posix.join(n,"server","pages","[...route].js.nft.json"),m=await x(`**/${l}/${f}/**`,{cwd:i,onlyFiles:!0}),a=JSON.parse(await o.promises.readFile(t,"utf-8"));m.forEach(d=>{let u=e.posix.dirname(t),h=e.posix.relative(u,e.posix.resolve(d));a.files.push(h)}),await o.promises.writeFile(t,JSON.stringify(a))}}export{j as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u,b as p}from"./chunk-DYNA3PMW.mjs";import g from"fastify-plugin";function F(a,y,m){let{prefix:r}=y,{config:l,fs:h,core:f}=a.mosaic;a.get(`/${r}/config`,async(i,e)=>{e.header("Content-Type","application/json");let s=l.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=p(u({},n),{credentials:`${d[0]}: ********`}))}return t}),o=p(u({},l),{sources:s});e.send(o)}),a.get(`/${r}/content/dump`,(i,e)=>{e.header("Content-Type","application/json"),e.send(h.toJSON())}),a.get(`/${r}/sources/list`,async(i,e)=>{e.header("Content-Type","application/json");let o=(await f.listSources()).map(t=>{let n=l.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=p(u({},c),{credentials:`${d[0]}: ********`}))}return p(u({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 f.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 f.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"),!y.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 f.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)}}),m()}var S=g(F,{fastify:"4.x",name:"fastify-mosaic-admin",dependencies:["fastify-mosaic"]});export{S as a};
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as e}from"./chunk-ND7PMTGH.mjs";import{b as s}from"./chunk-HQMO6BLF.mjs";import"./chunk-6E5PQQKS.mjs";import{a as p}from"./chunk-P3RXN7HU.mjs";import{a as n}from"./chunk-VIYGD5XX.mjs";import"./chunk-FCNWFPGR.mjs";import"./chunk-Y6WPZ5AX.mjs";import"./chunk-IMOZUZOL.mjs";import"./chunk-DYNA3PMW.mjs";import{program as r}from"commander";import i from"path";import{pathToFileURL as a}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").option("-n, --name <string>","Snapshot name").option("-S, --snapshot <string>","Snapshot path");r.parse();var o=r.opts(),t;if(o.config!==void 0){if(t=await import(a(i.resolve(process.cwd(),o.config)).toString()),!t)throw new Error(`[Mosaic] could not find config file at ${i.resolve(process.cwd(),o.config)}.`)}else throw new Error("[Mosaic] no config file provided");r.args[0]==="build"&&e(t.default,i.resolve(process.cwd(),o.out),o);r.args[0]==="serve"&&s(t.default,o.port,o.scope&&o.scope.split(","));r.args[0]==="upload"&&p(i.resolve(process.cwd(),o.snapshot));r.args[0]==="deploy"&&n(t.default,o);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-FCNWFPGR.mjs";import"../chunk-DYNA3PMW.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-Y6WPZ5AX.mjs";import"../chunk-DYNA3PMW.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";import"../chunk-DYNA3PMW.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-6E5PQQKS.mjs";import"../chunk-DYNA3PMW.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, import("http").IncomingMessage, import("http").ServerResponse, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault> & PromiseLike<Fastify.FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, 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-HQMO6BLF.mjs";import"./chunk-6E5PQQKS.mjs";import"./chunk-FCNWFPGR.mjs";import"./chunk-Y6WPZ5AX.mjs";import"./chunk-IMOZUZOL.mjs";import"./chunk-DYNA3PMW.mjs";export{b as default,a as server};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function uploadS3Snapshot(targetDir: any): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-P3RXN7HU.mjs";import"./chunk-DYNA3PMW.mjs";export{a as default};
|
|
@@ -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-VIYGD5XX.mjs";import"./chunk-DYNA3PMW.mjs";export{a as updateTraceFile};
|
package/package.json
CHANGED
|
@@ -1,33 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-cli",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.80",
|
|
4
4
|
"author": "",
|
|
5
5
|
"description": "Mosaic command line scripts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"main": "./dist/index.
|
|
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
|
+
},
|
|
8
17
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
18
|
+
"node": ">=16.10.0 || >=18.0.0"
|
|
10
19
|
},
|
|
11
20
|
"bin": {
|
|
12
|
-
"mosaic": "./dist/index.
|
|
21
|
+
"mosaic": "./dist/index.mjs"
|
|
13
22
|
},
|
|
14
23
|
"files": [
|
|
15
24
|
"dist"
|
|
16
25
|
],
|
|
17
26
|
"scripts": {
|
|
18
|
-
"build": "
|
|
19
|
-
"
|
|
27
|
+
"build": "npm-run-all --parallel build:*",
|
|
28
|
+
"build:types": "tsc",
|
|
29
|
+
"build:cli": "node ./scripts/bundle.js",
|
|
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__/**\""
|
|
20
34
|
},
|
|
21
35
|
"repository": {
|
|
22
36
|
"type": "git",
|
|
23
|
-
"url": "git@github.com:jpmorganchase/mosaic.git"
|
|
37
|
+
"url": "git@github.com:jpmorganchase/mosaic.git",
|
|
38
|
+
"directory": "packages/cli"
|
|
24
39
|
},
|
|
25
40
|
"devDependencies": {
|
|
26
|
-
"@jpmorganchase/mosaic-
|
|
27
|
-
"
|
|
28
|
-
"
|
|
41
|
+
"@jpmorganchase/mosaic-types": "^0.1.0-beta.80",
|
|
42
|
+
"esbuild": "0.14.35",
|
|
43
|
+
"esbuild-node-externals": "^1.0.2",
|
|
44
|
+
"fast-glob": "^3.2.7",
|
|
45
|
+
"@types/ws": "^8.5.7"
|
|
29
46
|
},
|
|
30
47
|
"dependencies": {
|
|
48
|
+
"@jpmorganchase/mosaic-core": "^0.1.0-beta.80",
|
|
49
|
+
"@jpmorganchase/mosaic-plugins": "^0.1.0-beta.80",
|
|
50
|
+
"@jpmorganchase/mosaic-standard-generator": "^0.1.0-beta.80",
|
|
51
|
+
"@jpmorganchase/mosaic-source-local-folder": "^0.1.0-beta.80",
|
|
52
|
+
"@aws-sdk/client-s3": "^3.359.0",
|
|
53
|
+
"@fastify/middie": "^8.3.0",
|
|
54
|
+
"@fastify/websocket": "^8.2.0",
|
|
55
|
+
"commander": "^9.4.1",
|
|
56
|
+
"cors": "^2.8.5",
|
|
57
|
+
"deepmerge": "^4.2.2",
|
|
58
|
+
"fastify": "^4.23.2",
|
|
59
|
+
"fastify-plugin": "^4.5.1",
|
|
60
|
+
"fs-extra": "^10.1.0",
|
|
61
|
+
"globby": "^13.1.3",
|
|
62
|
+
"md5": "*",
|
|
31
63
|
"mkdirp": "^1.0.4"
|
|
32
64
|
}
|
|
33
65
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# @jpmorganchase/mosaic-cli
|
|
2
|
-
|
|
3
|
-
## 0.1.0-beta.8
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- 2dca0b1: initial release of Mosaic store package
|
|
8
|
-
|
|
9
|
-
## 0.1.0-beta.7
|
|
10
|
-
|
|
11
|
-
### Minor Changes
|
|
12
|
-
|
|
13
|
-
- f82c397: Initial release of theme and client side search
|
|
14
|
-
|
|
15
|
-
We are iterating towards deploying our site code.
|
|
16
|
-
|
|
17
|
-
This release includes
|
|
18
|
-
|
|
19
|
-
- initial work for client-side search support
|
|
20
|
-
- Mosaic theme.
|
|
21
|
-
|
|
22
|
-
## 0.1.0-beta.6
|
|
23
|
-
|
|
24
|
-
### Patch Changes
|
|
25
|
-
|
|
26
|
-
- c103b24: Release fixes for snapshot serve
|
|
27
|
-
|
|
28
|
-
## 0.1.0-beta.5
|
|
29
|
-
|
|
30
|
-
### Patch Changes
|
|
31
|
-
|
|
32
|
-
- 61a246c: This releases add support for generate / build and serve snapshots
|
|
33
|
-
|
|
34
|
-
## 0.1.0-beta.4
|
|
35
|
-
|
|
36
|
-
### Patch Changes
|
|
37
|
-
|
|
38
|
-
- bd285df: added dist to package.json
|
|
39
|
-
|
|
40
|
-
## 0.1.0-beta.3
|
|
41
|
-
|
|
42
|
-
### Patch Changes
|
|
43
|
-
|
|
44
|
-
- 457df5e: switch to public package
|
|
45
|
-
|
|
46
|
-
## 0.1.0-beta.2
|
|
47
|
-
|
|
48
|
-
### Patch Changes
|
|
49
|
-
|
|
50
|
-
- e1bbbe7: Initial release of Mosaic Core file-system.
|
|
51
|
-
|
|
52
|
-
Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
|
|
53
|
-
|
|
54
|
-
- 4b2bc51: pipped to 0.1.0-beta.1 for publishing to NPM
|
|
55
|
-
|
|
56
|
-
## 0.1.0
|
|
57
|
-
|
|
58
|
-
### Patch Changes
|
|
59
|
-
|
|
60
|
-
- e1bbbe7: Initial release of Mosaic Core file-system.
|
|
61
|
-
|
|
62
|
-
Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
|
package/dist/build.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
const { default: Mosaic } = require('@jpmorganchase/mosaic-core');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const fsExtra = require('fs-extra');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
|
|
6
|
-
module.exports = async (config, targetDir, options) => {
|
|
7
|
-
// Strip out any plugins that are meant for runtime use only (i.e. `LazyPagePlugin`)
|
|
8
|
-
config.plugins = config.plugins.filter(({ runTimeOnly }) => !runTimeOnly);
|
|
9
|
-
// Turn off `cache` for each source
|
|
10
|
-
config.sources = config.sources.map(source => ({
|
|
11
|
-
...source,
|
|
12
|
-
options: { ...source.options, cache: false }
|
|
13
|
-
}));
|
|
14
|
-
const scope = options.scope && options.scope.split(',');
|
|
15
|
-
const mosaic = new Mosaic(config);
|
|
16
|
-
const pathDir = path.posix.join(targetDir, options.name ?? new Date().toISOString());
|
|
17
|
-
await fsExtra.emptyDir(pathDir);
|
|
18
|
-
await mosaic.start();
|
|
19
|
-
// If `scope` arg was used, scope the filesystem to those namespaces
|
|
20
|
-
const filesystem = Array.isArray(scope) ? mosaic.filesystem.scope(scope) : mosaic.filesystem;
|
|
21
|
-
let calls = 0;
|
|
22
|
-
mosaic.onSourceUpdate(async (value, source) => {
|
|
23
|
-
try {
|
|
24
|
-
if (++calls === config.sources.length) {
|
|
25
|
-
const symlinks = filesystem.symlinksToJSON();
|
|
26
|
-
const allFiles = await filesystem.promises.glob('**', {
|
|
27
|
-
cwd: '/',
|
|
28
|
-
onlyFiles: true
|
|
29
|
-
});
|
|
30
|
-
for (const filePath of allFiles) {
|
|
31
|
-
// if (dotDirRegExp.test(filePath)) {
|
|
32
|
-
// continue;
|
|
33
|
-
// }
|
|
34
|
-
const rawFiles = await filesystem.promises.readFile(String(filePath), {
|
|
35
|
-
includeConflicts: true
|
|
36
|
-
});
|
|
37
|
-
let rawFile = rawFiles[0];
|
|
38
|
-
if (rawFiles.length > 1) {
|
|
39
|
-
// TODO: We could join colliding JSON files together. e.g. sidebar.json files
|
|
40
|
-
// if (path.basename(String(filePath)).startsWith('.') && path.extname(String(filePath)) === '.json') {
|
|
41
|
-
// console.warn(`'${filePath}' returned multiple files at the same location. Since the files were JSON dot files, they were merged using a basic Lodash \`merge\`.`);
|
|
42
|
-
// rawFile = Buffer.from(JSON.stringify(merge(...rawFiles.map(fileData => JSON.parse(String(fileData))))));
|
|
43
|
-
// } else {
|
|
44
|
-
throw new Error(`'${filePath}' returned multiple files at the same location, this will result in overwritten data in the output. Aborting build.
|
|
45
|
-
|
|
46
|
-
Try using \`--scope\` to just output certain namespaced sources, or adding a \`prefixDir\` to the source options to move the source files into a separate folder.`);
|
|
47
|
-
}
|
|
48
|
-
//}
|
|
49
|
-
await fs.promises.mkdir(path.dirname(path.join(pathDir, String(filePath))), {
|
|
50
|
-
recursive: true
|
|
51
|
-
});
|
|
52
|
-
await fs.promises.writeFile(path.join(pathDir, String(filePath)), rawFile);
|
|
53
|
-
}
|
|
54
|
-
for (const alias in symlinks) {
|
|
55
|
-
if (alias.startsWith('/.tags')) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
for (const { target } of symlinks[alias]) {
|
|
59
|
-
if (target.startsWith('/.tags')) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
await fsExtra.ensureDir(path.join(pathDir, path.dirname(alias)));
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
const exists = !!(await fs.promises.stat(path.join(pathDir, alias)));
|
|
66
|
-
if (exists) {
|
|
67
|
-
console.error(
|
|
68
|
-
new Error(
|
|
69
|
-
`Symlink at '${path.join(pathDir, alias)}' already exists. Aborting build.`
|
|
70
|
-
)
|
|
71
|
-
);
|
|
72
|
-
process.exit(1);
|
|
73
|
-
}
|
|
74
|
-
} catch {
|
|
75
|
-
await fs.promises.symlink(path.join(pathDir, target), path.join(pathDir, alias));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
console.log(
|
|
81
|
-
`Filesystem for ${
|
|
82
|
-
Array.isArray(scope) ? scope.length : config.sources.length
|
|
83
|
-
} source(s) written to disk at '${pathDir}'`
|
|
84
|
-
);
|
|
85
|
-
mosaic.stop();
|
|
86
|
-
}
|
|
87
|
-
} catch (e) {
|
|
88
|
-
console.error(e);
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
};
|
package/dist/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { program } = require('commander');
|
|
4
|
-
const serve = require('./serve');
|
|
5
|
-
const serveSnapshot = require('./serve-snapshot');
|
|
6
|
-
const build = require('./build');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
|
|
9
|
-
program
|
|
10
|
-
.option('-c, --config <string>', 'Config path')
|
|
11
|
-
.option('-o, --out <string>', 'Output directory', '.tmp/.mosaic-build')
|
|
12
|
-
.option('-s, --scope <strings>', 'Command separated namespaces')
|
|
13
|
-
.option('-p, --port <number>', 'Port to serve on', 8080)
|
|
14
|
-
.option('-n, --name <string>', 'Snapshot name')
|
|
15
|
-
.option('-S, --snapshot <string>', 'Snapshot path');
|
|
16
|
-
|
|
17
|
-
program.parse();
|
|
18
|
-
|
|
19
|
-
const options = program.opts();
|
|
20
|
-
|
|
21
|
-
if (program.args[0] === 'build') {
|
|
22
|
-
if (options.config !== undefined) {
|
|
23
|
-
const config = require(path.resolve(process.cwd(), options.config));
|
|
24
|
-
if (!config) {
|
|
25
|
-
throw new Error(
|
|
26
|
-
`Could not find config file at ${path.resolve(process.cwd(), options.config)}.`
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
build(config, path.resolve(process.cwd(), options.out), options);
|
|
30
|
-
}
|
|
31
|
-
} else if (program.args[0] === 'serve') {
|
|
32
|
-
if (options.snapshot !== undefined) {
|
|
33
|
-
const targetDir = path.resolve(process.cwd(), options.snapshot);
|
|
34
|
-
serveSnapshot(targetDir, options.port, options.scope && options.scope.split(','));
|
|
35
|
-
}
|
|
36
|
-
if (options.config !== undefined) {
|
|
37
|
-
const config = require(path.resolve(process.cwd(), options.config));
|
|
38
|
-
if (!config) {
|
|
39
|
-
throw new Error(
|
|
40
|
-
`Could not find config file at ${path.resolve(process.cwd(), options.config)}.`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
serve(config, options.port, options.scope && options.scope.split(','));
|
|
44
|
-
}
|
|
45
|
-
}
|
package/dist/serve-snapshot.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const express = require('express');
|
|
2
|
-
const cors = require('cors');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
const app = express();
|
|
6
|
-
|
|
7
|
-
module.exports = async (targetDir, port, scope) => {
|
|
8
|
-
app.listen(port, () => {
|
|
9
|
-
console.log(
|
|
10
|
-
`Serving ${targetDir} on port ${port}${
|
|
11
|
-
Array.isArray(scope) ? ` (scoped to ${scope.join(', ')})` : ''
|
|
12
|
-
}`
|
|
13
|
-
);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const fs = require('fs');
|
|
17
|
-
|
|
18
|
-
app.use(cors());
|
|
19
|
-
app.get('/**', async (req, res) => {
|
|
20
|
-
const fullPath = path.posix.join(targetDir, req.path);
|
|
21
|
-
try {
|
|
22
|
-
fs.stat(fullPath, (err, stats) => {
|
|
23
|
-
if (err) {
|
|
24
|
-
console.error(`[Mosaic] snapshot for ${fullPath} not found... sending 404..\n`, err);
|
|
25
|
-
res.status(404).end();
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (stats != undefined) {
|
|
29
|
-
if (stats.isDirectory()) {
|
|
30
|
-
fs.stat(path.join(fullPath, 'index'), (err, _stats) => {
|
|
31
|
-
if (err) {
|
|
32
|
-
console.error(
|
|
33
|
-
`[Mosaic] No index found in snapshot directory ${fullPath} ... sending 404 ...\n`,
|
|
34
|
-
err
|
|
35
|
-
);
|
|
36
|
-
res.status(404).end();
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
console.info(`[Mosaic] sending redirect to for snapshot ${fullPath} ... \n`);
|
|
40
|
-
res.status(302).json({ redirect: path.join(req.path, 'index') });
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
fs.realpath(fullPath, (err, pagePath) => {
|
|
44
|
-
if (err) {
|
|
45
|
-
console.error(
|
|
46
|
-
`[Mosaic] snapshot not found for ${fullPath} ... sending 404 ...\n`,
|
|
47
|
-
err
|
|
48
|
-
);
|
|
49
|
-
res.status(404).end();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
fs.readFile(pagePath, (err, data) => {
|
|
53
|
-
if (err) {
|
|
54
|
-
console.error(
|
|
55
|
-
`[Mosaic] unable to read file for ${fullPath} / ${pagePath} ... sending 404 ...\n`,
|
|
56
|
-
err
|
|
57
|
-
);
|
|
58
|
-
res.status(404).end();
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (path.extname(pagePath) === '.mdx') {
|
|
62
|
-
res.contentType('text/mdx');
|
|
63
|
-
} else if (path.extname(pagePath) === '.json') {
|
|
64
|
-
res.contentType('application/json');
|
|
65
|
-
} else if (path.extname(pagePath) === '.xml') {
|
|
66
|
-
res.contentType('application/xml');
|
|
67
|
-
}
|
|
68
|
-
console.info(`[Mosaic] sending data for ${fullPath} / ${pagePath} ... `);
|
|
69
|
-
res.send(data);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
console.error(
|
|
75
|
-
`[Mosaic] cannot fs.stat anything in snapshot for ${fullPath} ... sending 404..\n`,
|
|
76
|
-
err
|
|
77
|
-
);
|
|
78
|
-
res.status(404).end();
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
} catch (e) {
|
|
82
|
-
console.error(`[Mosaic] `, e);
|
|
83
|
-
res.status(500).end();
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
};
|
package/dist/serve.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const express = require('express');
|
|
2
|
-
const cors = require('cors');
|
|
3
|
-
const { default: MosaicCore } = require('@jpmorganchase/mosaic-core');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
const app = express();
|
|
7
|
-
|
|
8
|
-
module.exports = async (config, port, scope) => {
|
|
9
|
-
app.listen(port, () => {
|
|
10
|
-
console.log(
|
|
11
|
-
`[Mosaic] Listening on port ${port}${
|
|
12
|
-
Array.isArray(scope) ? ` (scoped to ${scope.join(', ')})` : ''
|
|
13
|
-
}`
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
const mosaic = new MosaicCore(config);
|
|
17
|
-
await mosaic.start();
|
|
18
|
-
|
|
19
|
-
const fs = Array.isArray(scope) ? mosaic.filesystem.scope(scope) : mosaic.filesystem;
|
|
20
|
-
|
|
21
|
-
app.use(cors(), express.json());
|
|
22
|
-
|
|
23
|
-
app.get('/**', async (req, res) => {
|
|
24
|
-
try {
|
|
25
|
-
if (await fs.promises.exists(req.path)) {
|
|
26
|
-
if ((await fs.promises.stat(req.path)).isDirectory()) {
|
|
27
|
-
if (await fs.promises.exists(path.join(req.path, 'index'))) {
|
|
28
|
-
// Don't do an actual redirect - just send the URL as the response
|
|
29
|
-
res.status(302).json({ redirect: path.join(req.path, 'index') });
|
|
30
|
-
} else {
|
|
31
|
-
res.status(404).end();
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
const pagePath = await fs.promises.realpath(req.path);
|
|
35
|
-
if (path.extname(pagePath) === '.mdx') {
|
|
36
|
-
res.contentType('text/mdx');
|
|
37
|
-
} else if (path.extname(pagePath) === '.json') {
|
|
38
|
-
res.contentType('application/json');
|
|
39
|
-
} else if (path.extname(pagePath) === '.xml') {
|
|
40
|
-
res.contentType('application/xml');
|
|
41
|
-
}
|
|
42
|
-
const result = await fs.promises.readFile(req.path);
|
|
43
|
-
res.send(result);
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
res.status(404).end();
|
|
47
|
-
}
|
|
48
|
-
} catch (e) {
|
|
49
|
-
console.error(e);
|
|
50
|
-
res.status(500).end();
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
app.post('/workflows', async (req, res) => {
|
|
55
|
-
try {
|
|
56
|
-
const { user, route: routeReq, markdown, name } = req.body;
|
|
57
|
-
|
|
58
|
-
if (!name) {
|
|
59
|
-
throw new Error('Workflow name is required');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (await fs.promises.exists(routeReq)) {
|
|
63
|
-
const route = (await fs.promises.stat(routeReq)).isDirectory()
|
|
64
|
-
? path.posix.join(routeReq, 'index')
|
|
65
|
-
: routeReq;
|
|
66
|
-
const pagePath = await fs.promises.realpath(route);
|
|
67
|
-
const result = await mosaic.triggerWorkflow(name, pagePath, { user, markdown });
|
|
68
|
-
res.contentType('application/json');
|
|
69
|
-
res.send(result);
|
|
70
|
-
}
|
|
71
|
-
} catch (e) {
|
|
72
|
-
console.error(e);
|
|
73
|
-
res.status(500).send(e.message).end();
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
};
|