@jpmorganchase/mosaic-cli 0.1.0-beta.6 → 0.1.0-beta.8
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/CHANGELOG.md +19 -0
- package/dist/build.js +6 -6
- package/dist/serve-snapshot.js +8 -8
- package/dist/serve.js +29 -6
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @jpmorganchase/mosaic-cli
|
|
2
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
|
+
|
|
3
22
|
## 0.1.0-beta.6
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/build.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { default:
|
|
1
|
+
const { default: Mosaic } = require('@jpmorganchase/mosaic-core');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fsExtra = require('fs-extra');
|
|
4
4
|
const fs = require('fs');
|
|
@@ -12,14 +12,14 @@ module.exports = async (config, targetDir, options) => {
|
|
|
12
12
|
options: { ...source.options, cache: false }
|
|
13
13
|
}));
|
|
14
14
|
const scope = options.scope && options.scope.split(',');
|
|
15
|
-
const
|
|
15
|
+
const mosaic = new Mosaic(config);
|
|
16
16
|
const pathDir = path.posix.join(targetDir, options.name ?? new Date().toISOString());
|
|
17
17
|
await fsExtra.emptyDir(pathDir);
|
|
18
|
-
await
|
|
18
|
+
await mosaic.start();
|
|
19
19
|
// If `scope` arg was used, scope the filesystem to those namespaces
|
|
20
|
-
const filesystem = Array.isArray(scope) ?
|
|
20
|
+
const filesystem = Array.isArray(scope) ? mosaic.filesystem.scope(scope) : mosaic.filesystem;
|
|
21
21
|
let calls = 0;
|
|
22
|
-
|
|
22
|
+
mosaic.onSourceUpdate(async (value, source) => {
|
|
23
23
|
try {
|
|
24
24
|
if (++calls === config.sources.length) {
|
|
25
25
|
const symlinks = filesystem.symlinksToJSON();
|
|
@@ -82,7 +82,7 @@ Try using \`--scope\` to just output certain namespaced sources, or adding a \`p
|
|
|
82
82
|
Array.isArray(scope) ? scope.length : config.sources.length
|
|
83
83
|
} source(s) written to disk at '${pathDir}'`
|
|
84
84
|
);
|
|
85
|
-
|
|
85
|
+
mosaic.stop();
|
|
86
86
|
}
|
|
87
87
|
} catch (e) {
|
|
88
88
|
console.error(e);
|
package/dist/serve-snapshot.js
CHANGED
|
@@ -21,7 +21,7 @@ module.exports = async (targetDir, port, scope) => {
|
|
|
21
21
|
try {
|
|
22
22
|
fs.stat(fullPath, (err, stats) => {
|
|
23
23
|
if (err) {
|
|
24
|
-
console.error(`[
|
|
24
|
+
console.error(`[Mosaic] snapshot for ${fullPath} not found... sending 404..\n`, err);
|
|
25
25
|
res.status(404).end();
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
@@ -30,20 +30,20 @@ module.exports = async (targetDir, port, scope) => {
|
|
|
30
30
|
fs.stat(path.join(fullPath, 'index'), (err, _stats) => {
|
|
31
31
|
if (err) {
|
|
32
32
|
console.error(
|
|
33
|
-
`[
|
|
33
|
+
`[Mosaic] No index found in snapshot directory ${fullPath} ... sending 404 ...\n`,
|
|
34
34
|
err
|
|
35
35
|
);
|
|
36
36
|
res.status(404).end();
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
console.info(`[
|
|
39
|
+
console.info(`[Mosaic] sending redirect to for snapshot ${fullPath} ... \n`);
|
|
40
40
|
res.status(302).json({ redirect: path.join(req.path, 'index') });
|
|
41
41
|
});
|
|
42
42
|
} else {
|
|
43
43
|
fs.realpath(fullPath, (err, pagePath) => {
|
|
44
44
|
if (err) {
|
|
45
45
|
console.error(
|
|
46
|
-
`[
|
|
46
|
+
`[Mosaic] snapshot not found for ${fullPath} ... sending 404 ...\n`,
|
|
47
47
|
err
|
|
48
48
|
);
|
|
49
49
|
res.status(404).end();
|
|
@@ -52,7 +52,7 @@ module.exports = async (targetDir, port, scope) => {
|
|
|
52
52
|
fs.readFile(pagePath, (err, data) => {
|
|
53
53
|
if (err) {
|
|
54
54
|
console.error(
|
|
55
|
-
`[
|
|
55
|
+
`[Mosaic] unable to read file for ${fullPath} / ${pagePath} ... sending 404 ...\n`,
|
|
56
56
|
err
|
|
57
57
|
);
|
|
58
58
|
res.status(404).end();
|
|
@@ -65,21 +65,21 @@ module.exports = async (targetDir, port, scope) => {
|
|
|
65
65
|
} else if (path.extname(pagePath) === '.xml') {
|
|
66
66
|
res.contentType('application/xml');
|
|
67
67
|
}
|
|
68
|
-
console.info(`[
|
|
68
|
+
console.info(`[Mosaic] sending data for ${fullPath} / ${pagePath} ... `);
|
|
69
69
|
res.send(data);
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
} else {
|
|
74
74
|
console.error(
|
|
75
|
-
`[
|
|
75
|
+
`[Mosaic] cannot fs.stat anything in snapshot for ${fullPath} ... sending 404..\n`,
|
|
76
76
|
err
|
|
77
77
|
);
|
|
78
78
|
res.status(404).end();
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
} catch (e) {
|
|
82
|
-
console.error(`[
|
|
82
|
+
console.error(`[Mosaic] `, e);
|
|
83
83
|
res.status(500).end();
|
|
84
84
|
}
|
|
85
85
|
});
|
package/dist/serve.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const express = require('express');
|
|
2
2
|
const cors = require('cors');
|
|
3
|
-
const { default:
|
|
3
|
+
const { default: MosaicCore } = require('@jpmorganchase/mosaic-core');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
|
|
6
6
|
const app = express();
|
|
@@ -8,17 +8,17 @@ const app = express();
|
|
|
8
8
|
module.exports = async (config, port, scope) => {
|
|
9
9
|
app.listen(port, () => {
|
|
10
10
|
console.log(
|
|
11
|
-
`[
|
|
11
|
+
`[Mosaic] Listening on port ${port}${
|
|
12
12
|
Array.isArray(scope) ? ` (scoped to ${scope.join(', ')})` : ''
|
|
13
13
|
}`
|
|
14
14
|
);
|
|
15
15
|
});
|
|
16
|
-
const
|
|
17
|
-
await
|
|
16
|
+
const mosaic = new MosaicCore(config);
|
|
17
|
+
await mosaic.start();
|
|
18
18
|
|
|
19
|
-
const fs = Array.isArray(scope) ?
|
|
19
|
+
const fs = Array.isArray(scope) ? mosaic.filesystem.scope(scope) : mosaic.filesystem;
|
|
20
20
|
|
|
21
|
-
app.use(cors());
|
|
21
|
+
app.use(cors(), express.json());
|
|
22
22
|
|
|
23
23
|
app.get('/**', async (req, res) => {
|
|
24
24
|
try {
|
|
@@ -50,4 +50,27 @@ module.exports = async (config, port, scope) => {
|
|
|
50
50
|
res.status(500).end();
|
|
51
51
|
}
|
|
52
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
|
+
});
|
|
53
76
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-cli",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.8",
|
|
4
4
|
"author": "",
|
|
5
5
|
"description": "Mosaic command line scripts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "
|
|
18
|
+
"build": "mkdirp dist && cp -f src/** dist",
|
|
19
19
|
"clean": "rm -fr dist"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
@@ -23,8 +23,11 @@
|
|
|
23
23
|
"url": "git@github.com:jpmorganchase/mosaic.git"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@jpmorganchase/mosaic-core": "^0.1.0-beta.
|
|
27
|
-
"@jpmorganchase/mosaic-types": "^0.1.0-beta.
|
|
26
|
+
"@jpmorganchase/mosaic-core": "^0.1.0-beta.8",
|
|
27
|
+
"@jpmorganchase/mosaic-types": "^0.1.0-beta.8",
|
|
28
28
|
"commander": "^9.3.0"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"mkdirp": "^1.0.4"
|
|
29
32
|
}
|
|
30
33
|
}
|