-
Notifications
You must be signed in to change notification settings - Fork 19
/
mosaic.generators.js
184 lines (182 loc) · 8.43 KB
/
mosaic.generators.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/**
* Mosaic
* (this file was generated by @jpmorganchase/mosaic-create-site)
*
* 1. Create your first site
*
* Generate an initial Mosaic site with
*
* > yarn mosaic-create-site create -g mosaic -o <path to your output directory>
*
* OR run in interactive mode to see the other generators that are available
*
* > yarn mosaic-create-site create -i -o <path to your output directory>
*
* 2. Configuration
*
* Mosaic is composed of 2 services, the Mosaic Site and the Mosaic Core Filesystem.
*
* What is the Mosaic Core File System
*
* The Mosaic Core Filesystem is composed of aggregated content from heterogeneous data sources.
* The Mosaic Core Filesystem config defines sources & plugins which translate your content to the Mosaic design language.
*
* Sources are remote content sources which Mosaic will pull content from.
* Plugins are composible features which can create pages or add existing content/metadata to existing pages.
*
* What is the Mosaic Site service ?
*
* The Mosaic site is a Next JS app which reads from the Mosaic Filesystem and renders the pages using configurable components, layouts and theme.
* The configuration of the site is handled by the `mosaic-create-site` which generates a pre-configured site.
*
* How do you setup a Mosaic site ?
*
* The initial sources/config for a Mosaic site is generated by a bin script `mosaic-create-site` which provides a menu of available site generators.
* Mosaic generators are PlopJS (http://plopjs.com) files.
*
* Multiple site generators are available which can be configured via a file called `mosaic.generators.js`.
*
* To just create `mosaic.generators.js`, run
* > yarn mosaic-create-site init
* Alternatively, when you run `mosaic-create-site` you can specify your generator config via the `--config` argument.
* If no generator config is specified and one does not exist in the current directory, one will be created for you.
* You can edit this file and re-run the create command to generate a non-default site.
*
* How can I configure my own components, theme or layouts to the Mosaic site ?
*
* In `mosaic.generators.js` the callback `getGenerators()` can be used to configure the generated `_app.tsx` with additional components, theme or layouts.
*
* To extend Mosaic with your own components/theme or layouts, you can keep all the existing Mosaic plugin configurations and just configure
* components, layout and theme (You don't need to do all 3, just what is required)
*
* You can even add additional imports which might be required by your generated site.
* Here is a kitchen sink view of the standard generator being configured with `sources`, `dependencies` and `imports`
*
* const { getGenerators } = require('@jpmorganchase/mosaic-create-site');
* const standardGeneratorConfig = require('@jpmorganchase/mosaic-standard-generator/dist/generator.config.js');
*
* module.exports = {
* generators: [
* ...getGenerators()
* [
* '@jpmorganchase/mosaic-standard-generator/dist/generator.js',
* {
* ...standardGeneratorConfig,
* generatorName: 'rig', // name of generator used in interactive mode
* name: '@jpmorganchase/mosaic-rig', // package name
* namespace: 'rig',
* description: "Mosaic Development Rig",
* homepage: '/rig',
* // To add your own Source, add a sources entry
* sources: [
* {
* modulePath: require.resolve('@jpmorganchase/mosaic-source-git-repo'),
* namespace: 'rig', // each site has it's own namespace, think of this as your content's uid
* options: {
* // To run locally, enter your credentials to access the BitBucket repo
* // !! Polite Reminder... do not store credentials in code !!
* // For final deployments, you could put repo access credentials securely in environment variables provided by Gaia console.
* // credentials: "{process.env.FID}:{process.env.FID_PERSONAL_ACCESS_TOKEN}",
* // If running locally
* // create an environment variable like MOSAIC_DOCS_CLONE_CREDENTIALS to let the user define it via the CLI
* // export MOSAIC_DOCS_CLONE_CREDENTIALS="<sid>:<Personal Access Token (PAT) provided by your Repo OR password>",
* credentials: process.env.MOSAIC_DOCS_CLONE_CREDENTIALS,
* prefixDir: 'rig',
* subfolder: 'docs', // subfolder within your branch containing the docs, typically 'docs'
* repo: 'github.com/jpmorganchase/mosaic.git', // repo url without any protocol
* branch: 'main', // branch where docs are pulled from
* extensions: ['.mdx'], // extensions of content which should be pulled
* remote: 'origin' // what is the shorthand name of the remote repo, typically 'origin'
* }
* }
* ],
* dependencies: [
* { package: "@my-package/components", version: "^1.0.0" },
* { package: "@my-package/layouts", version: "^1.0.0" },
* { package: "@my-package/theme", version: "^1.0.0" },
* ],
* imports: [
* {
* import: "import myComponents from '@my-package/components';",
* identifier: "myComponents",
* type: "component",
* },
* {
* import: "import myLayouts from '@my-package/layouts';",
* identifier: "myLayouts",
* type: "layout",
* },
* {
* import: "import '@my-package/theme/dist/index.css';",
* }
* ]
* }
* ]
* ]
* };
*
* Alternatively, create your own generator and use that instead.
*
* 3. Site Generation
*
* Once you have created `mosaic.generators.js` (and configured any customisations) you can generate your site.
*
* To generate a site run
*
* > yarn mosaic-create-site create -o <path to site> -i
*
* From the menu, selector the required generator with the required templates/config.
*
* How can I add my own content ?
*
* Once you have generated a site, edit the file `mosaic.config.mjs` and add/configure a source entry.
*
*/
const { getGenerators } = require('@jpmorganchase/mosaic-create-site');
const standardGeneratorConfig = require('@jpmorganchase/mosaic-standard-generator/dist/generator.config.js');
const { version } = require('@jpmorganchase/mosaic-standard-generator/package.json');
module.exports = {
/** generators defines an array of Mosaic generators and associated config, which configure your generated site
* e.g
* generators: 'path to generator' | [ 'path to generator', { config } ]
*
* If you want to add generators, add elements to the array
* If you want to delete a generator, remove it from the array
*/
generators: [
...getGenerators(),
[
'@jpmorganchase/mosaic-standard-generator/dist/generator.js',
{
...standardGeneratorConfig,
version,
generatorName: 'rig',
name: '@jpmorganchase/mosaic-rig',
namespace: 'rig',
description: 'Development Rig Generator',
homepage: '/rig',
sources: [
{
modulePath: require.resolve('@jpmorganchase/mosaic-source-git-repo'),
namespace: 'rig', // each site has it's own namespace, think of this as your content's uid
options: {
// To run locally, enter your credentials to access the Git repo
// e.g create the environment variable MOSAIC_DOCS_CLONE_CREDENTIALS
// !! Polite Reminder... do not store credentials in code !!
// For final deployments: you could put repo access credentials securely in environment variables provided by your host.
// If running locally: create the environment variable MOSAIC_DOCS_CLONE_CREDENTIALS
// export MOSAIC_DOCS_CLONE_CREDENTIALS="<repo username>:<Personal Access Token (PAT) provided by your Repo OR password>",
credentials: process.env.MOSAIC_DOCS_CLONE_CREDENTIALS,
prefixDir: 'rig',
subfolder: 'docs', // subfolder within your branch containing the docs, typically 'docs'
repo: 'github.com/jpmorganchase/mosaic.git', // repo url without any protocol
branch: 'main', // branch where docs are pulled from
extensions: ['.mdx'], // extensions of content which should be pulled
remote: 'origin' // what is the shorthand name of the remote repo, typically 'origin'
}
}
]
}
]
]
};