create-gasket-app 7.0.0-next.60 → 7.0.0-next.61

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/index.d.ts CHANGED
@@ -37,7 +37,7 @@ export interface PluginInfo extends ModuleInfo {}
37
37
 
38
38
  export interface ConfigBuilder<Config> {
39
39
  /**
40
- * fields object
40
+ * fields object
41
41
  */
42
42
  fields: { [key: string]: any };
43
43
 
@@ -148,6 +148,35 @@ export interface Files {
148
148
  add(...args: string[]): void;
149
149
  }
150
150
 
151
+ export interface Readme {
152
+ /** Markdown content to be injected into the app readme */
153
+ markdown: string[];
154
+
155
+ /** Links to be added to the footer */
156
+ links: string[];
157
+
158
+ /** Add a markdown heading */
159
+ heading(content: string, level?: number): Readme;
160
+
161
+ /** Add a markdown sub-heading */
162
+ subHeading(content: string): Readme;
163
+
164
+ /** Add markdown content */
165
+ content(markdown: string);
166
+
167
+ /** Add a markdown list */
168
+ list(items: string[]): Readme;
169
+
170
+ /** Add a markdown link - printed in footer */
171
+ link(content: string, href: string): Readme;
172
+
173
+ /** Add a markdown code block */
174
+ codeBlock(content: string, syntax?: string): Readme;
175
+
176
+ /** Add markdown file */
177
+ markdownFile(path: string): Promise<Readme>;
178
+ }
179
+
151
180
  export interface CreateContext {
152
181
  /** Short name of the app */
153
182
  appName: string;
@@ -235,6 +264,9 @@ export interface CreateContext {
235
264
 
236
265
  /** Use to add files and templates to generate */
237
266
  files: Files;
267
+
268
+ /** Use to add content to the README.md */
269
+ readme: Readme;
238
270
  }
239
271
 
240
272
  export interface ActionWrapperParams {
@@ -1,6 +1,7 @@
1
1
  import action from '../action-wrapper.js';
2
2
  import { ConfigBuilder } from '../config-builder.js';
3
3
  import { Files } from '../files.js';
4
+ import Readme from '../readme.js';
4
5
 
5
6
  /**
6
7
  * Executes the `create` hook for all registered plugins.
@@ -14,8 +15,9 @@ async function createHooks({ gasket, context }) {
14
15
  const { plugins = [], warnings } = context;
15
16
 
16
17
  const files = new Files();
18
+ const readme = new Readme();
17
19
  const gasketConfig = ConfigBuilder.create({}, { orderBy: ['plugins'], warnings, plugins });
18
- Object.assign(context, { files, gasketConfig });
20
+ Object.assign(context, { files, readme, gasketConfig });
19
21
 
20
22
  await gasket.execApply('create', async function applyCreate(plugin, handler) {
21
23
  await handler(context.runWith(plugin));
@@ -109,7 +109,10 @@ async function performGenerate(context, descriptors) {
109
109
  handlebars.registerHelper('jspretty', (data) => {
110
110
  return JSON.stringify(data).replace(/"/g, '\'');
111
111
  });
112
- handlebars.registerHelper('eq', (a, b) => a === b)
112
+ handlebars.registerHelper('eq', (a, b) => a === b);
113
+ handlebars.registerHelper('markdownCompile', (data) => {
114
+ return handlebars.compile(data)(context);
115
+ });
113
116
 
114
117
  debug('descriptors', JSON.stringify(descriptors, null, 2));
115
118
 
@@ -170,7 +170,8 @@ export function makeCreateContext(argv = [], options = {}) {
170
170
  presets: [],
171
171
  presetConfig: {
172
172
  plugins: []
173
- }
173
+ },
174
+ readme: []
174
175
  });
175
176
 
176
177
  readConfig(context, { config, configFile });
@@ -0,0 +1,51 @@
1
+ import { readFile } from 'fs/promises';
2
+
3
+ /** @type {import('../index').Readme} */
4
+ export default class Readme {
5
+ constructor() {
6
+ this.markdown = [];
7
+ this.links = [];
8
+ }
9
+
10
+ addNewLine() {
11
+ this.markdown.push('');
12
+ return this;
13
+ }
14
+
15
+ heading(content, level = 2) {
16
+ this.markdown.push(`${'#'.repeat(level)} ${content}`);
17
+ return this.addNewLine();
18
+ }
19
+
20
+ subHeading(content) {
21
+ return this.heading(content, 3);
22
+ }
23
+
24
+ content(content) {
25
+ this.markdown.push(content);
26
+ return this.addNewLine();
27
+ }
28
+
29
+ list(items) {
30
+ this.markdown.push(...items.map(item => `- ${item}`));
31
+ return this.addNewLine();
32
+ }
33
+
34
+ link(content, href) {
35
+ this.links.push(`[${content}]: ${href}`);
36
+ return this;
37
+ }
38
+
39
+ codeBlock(content, syntax = '') {
40
+ this.markdown.push(`\`\`\`${syntax}`);
41
+ this.markdown.push(content);
42
+ this.markdown.push('```');
43
+ return this.addNewLine();
44
+ }
45
+
46
+ async markdownFile(path) {
47
+ const content = await readFile(path, 'utf8');
48
+ this.markdown.push(content);
49
+ return this.addNewLine();
50
+ }
51
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-gasket-app",
3
- "version": "7.0.0-next.60",
3
+ "version": "7.0.0-next.61",
4
4
  "description": "starter pack for creating a gasket app",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,14 +33,14 @@
33
33
  },
34
34
  "homepage": "https://github.com/godaddy/gasket/tree/main/packages/create-gasket-app",
35
35
  "dependencies": {
36
- "@gasket/core": "7.0.0-next.60",
37
- "@gasket/plugin-command": "7.0.0-next.60",
38
- "@gasket/plugin-docs": "7.0.0-next.60",
39
- "@gasket/plugin-docusaurus": "7.0.0-next.60",
40
- "@gasket/plugin-git": "7.0.0-next.60",
41
- "@gasket/plugin-logger": "7.0.0-next.60",
42
- "@gasket/plugin-metadata": "7.0.0-next.60",
43
- "@gasket/utils": "7.0.0-next.60",
36
+ "@gasket/core": "7.0.0-next.61",
37
+ "@gasket/plugin-command": "7.0.0-next.61",
38
+ "@gasket/plugin-docs": "7.0.0-next.61",
39
+ "@gasket/plugin-docusaurus": "7.0.0-next.61",
40
+ "@gasket/plugin-git": "7.0.0-next.61",
41
+ "@gasket/plugin-logger": "7.0.0-next.61",
42
+ "@gasket/plugin-metadata": "7.0.0-next.61",
43
+ "@gasket/utils": "7.0.0-next.61",
44
44
  "commander": "^12.0.0",
45
45
  "deepmerge": "^4.3.1",
46
46
  "glob": "^8.1.0",
@@ -83,5 +83,5 @@
83
83
  "jest": {
84
84
  "transform": {}
85
85
  },
86
- "gitHead": "ea9feae6cd291d4361c06e09659e50dbec19bcea"
86
+ "gitHead": "6bfc613e64088429e95e89211008b1c9ab530ca7"
87
87
  }