codify-plugin-lib 1.0.182-beta51 → 1.0.182-beta53

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/bin/build.js CHANGED
@@ -5,10 +5,8 @@ import mergeJsonSchemas from 'merge-json-schemas';
5
5
  import { fork } from 'node:child_process';
6
6
  import fs from 'node:fs';
7
7
  import path from 'node:path';
8
- import * as url from 'node:url';
9
8
 
10
- import { VerbosityLevel } from '../src/index';
11
- import { SequentialPty } from '../src/pty/seqeuntial-pty';
9
+ import { SequentialPty, VerbosityLevel } from '../dist/index.js';
12
10
 
13
11
  const ajv = new Ajv({
14
12
  strict: true
@@ -37,6 +35,58 @@ function sendMessageAndAwaitResponse(process, message) {
37
35
  });
38
36
  }
39
37
 
38
+ function fetchDocumentationMaps() {
39
+ console.log('Building documentation...');
40
+
41
+ const results = new Map();
42
+ const resourcesPath = path.resolve(process.cwd(), 'src', 'resources');
43
+ const resourcesDir = fs.readdirSync(resourcesPath);
44
+
45
+ for (const resource of resourcesDir) {
46
+ const resourcePath = path.join(resourcesPath, resource);
47
+ if (!isDirectory(resourcePath)) continue;
48
+
49
+ const contents = fs.readdirSync(resourcePath);
50
+ const isGroup = contents.some((content) => isDirectory(path.join(resourcePath, content)));
51
+ const isAllDir = contents.every((content) => isDirectory(path.join(resourcePath, content)));
52
+
53
+ if (isGroup && !isAllDir) {
54
+ throw new Error(`Documentation groups must only contain directories. ${resourcePath} does not`);
55
+ }
56
+
57
+ if (!isGroup) {
58
+ if (contents.includes('README.md')) {
59
+ results.set(resource, resource);
60
+ }
61
+ } else {
62
+ for (const innerDir of contents) {
63
+ const innerDirReadme = path.join(resourcePath, innerDir, 'README.md');
64
+ if (isFile(innerDirReadme)) {
65
+ results.set(innerDir, path.relative('./src/resources', path.join(resourcePath, innerDir)));
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
+ return results;
72
+ }
73
+
74
+ function isDirectory(path) {
75
+ try {
76
+ return fs.statSync(path).isDirectory();
77
+ } catch {
78
+ return false;
79
+ }
80
+ }
81
+
82
+ function isFile(path) {
83
+ try {
84
+ return fs.statSync(path).isFile();
85
+ } catch {
86
+ return false;
87
+ }
88
+ }
89
+
40
90
  VerbosityLevel.set(3);
41
91
  const $ = new SequentialPty();
42
92
 
@@ -61,6 +111,7 @@ const initializeResult = await sendMessageAndAwaitResponse(plugin, {
61
111
 
62
112
  const { resourceDefinitions } = initializeResult;
63
113
  const resourceTypes = resourceDefinitions.map((i) => i.type);
114
+ const resourceInfoMap = new Map();
64
115
 
65
116
  const schemasMap = new Map()
66
117
  for (const type of resourceTypes) {
@@ -70,8 +121,11 @@ for (const type of resourceTypes) {
70
121
  })
71
122
 
72
123
  schemasMap.set(type, resourceInfo.schema);
124
+ resourceInfoMap.set(type, resourceInfo);
73
125
  }
74
126
 
127
+ console.log(resourceInfoMap);
128
+
75
129
  const mergedSchemas = [...schemasMap.entries()].map(([type, schema]) => {
76
130
  // const resolvedSchema = await $RefParser.dereference(schema)
77
131
  const resourceSchema = JSON.parse(JSON.stringify(ResourceSchema));
@@ -98,12 +152,38 @@ await $.spawn('npm run rollup', { interactive: true }); // re-run rollup without
98
152
 
99
153
  console.log('Generated JSON Schemas for all resources')
100
154
 
101
- const distFolder = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..', 'dist');
155
+ const distFolder = path.resolve(process.cwd(), 'dist');
102
156
  const schemaOutputPath = path.resolve(distFolder, 'schemas.json');
103
157
  fs.writeFileSync(schemaOutputPath, JSON.stringify(mergedSchemas, null, 2));
104
158
 
105
- console.log('Successfully wrote schema to ./dist/schemas.json')
106
-
159
+ console.log('Successfully wrote schema to ./dist/schemas.json');
160
+
161
+ const documentationMap = fetchDocumentationMaps();
162
+
163
+ const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
164
+
165
+ fs.writeFileSync('./dist/manifest.json', JSON.stringify({
166
+ name: packageJson.name,
167
+ version: packageJson.version,
168
+ description: packageJson.description,
169
+ resources: [...resourceInfoMap.values()].map((info) => ({
170
+ type: info.type,
171
+ description: info.description ?? info.schema?.description,
172
+ sensitiveParameters: info.sensitiveParameters,
173
+ schema: info.schema,
174
+ operatingSystems: info.operatingSystems,
175
+ documentationKey: documentationMap.get(info.type),
176
+ })),
177
+ }, null, 2), 'utf8');
178
+
179
+ for (const key of documentationMap.values()) {
180
+ fs.mkdirSync(path.join('dist', 'documentation', key), { recursive: true })
181
+
182
+ fs.copyFileSync(
183
+ path.resolve(path.join('src', 'resources', key, 'README.md')),
184
+ path.resolve(path.join('dist', 'documentation', key, 'README.md')),
185
+ );
186
+ }
107
187
 
108
188
  plugin.kill(9);
109
189
  process.exit(0);
package/dist/index.d.ts CHANGED
@@ -5,7 +5,9 @@ export * from './plan/change-set.js';
5
5
  export * from './plan/plan.js';
6
6
  export * from './plan/plan-types.js';
7
7
  export * from './plugin/plugin.js';
8
+ export * from './pty/background-pty.js';
8
9
  export * from './pty/index.js';
10
+ export * from './pty/seqeuntial-pty.js';
9
11
  export * from './resource/parsed-resource-settings.js';
10
12
  export * from './resource/resource.js';
11
13
  export * from './resource/resource-settings.js';
package/dist/index.js CHANGED
@@ -5,7 +5,9 @@ export * from './plan/change-set.js';
5
5
  export * from './plan/plan.js';
6
6
  export * from './plan/plan-types.js';
7
7
  export * from './plugin/plugin.js';
8
+ export * from './pty/background-pty.js';
8
9
  export * from './pty/index.js';
10
+ export * from './pty/seqeuntial-pty.js';
9
11
  export * from './resource/parsed-resource-settings.js';
10
12
  export * from './resource/resource.js';
11
13
  export * from './resource/resource-settings.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.182-beta51",
3
+ "version": "1.0.182-beta53",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -7,7 +7,9 @@ export * from './plan/change-set.js'
7
7
  export * from './plan/plan.js'
8
8
  export * from './plan/plan-types.js'
9
9
  export * from './plugin/plugin.js'
10
+ export * from './pty/background-pty.js';
10
11
  export * from './pty/index.js'
12
+ export * from './pty/seqeuntial-pty.js';
11
13
  export * from './resource/parsed-resource-settings.js';
12
14
  export * from './resource/resource.js'
13
15
  export * from './resource/resource-settings.js'