@prismatic-io/spectral 8.1.7 → 9.0.0-rc.2
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/component-manifest.js +2 -0
- package/dist/generators/componentManifest/cli.d.ts +2 -0
- package/dist/generators/componentManifest/cli.js +134 -0
- package/dist/generators/componentManifest/createActions.d.ts +13 -0
- package/dist/generators/componentManifest/createActions.js +95 -0
- package/dist/generators/componentManifest/createConnections.d.ts +13 -0
- package/dist/generators/componentManifest/createConnections.js +95 -0
- package/dist/generators/componentManifest/createDataSources.d.ts +13 -0
- package/dist/generators/componentManifest/createDataSources.js +95 -0
- package/dist/generators/componentManifest/createStaticFiles.d.ts +80 -0
- package/dist/generators/componentManifest/createStaticFiles.js +145 -0
- package/dist/generators/componentManifest/createTriggers.d.ts +13 -0
- package/dist/generators/componentManifest/createTriggers.js +95 -0
- package/dist/generators/componentManifest/getImports.d.ts +7 -0
- package/dist/generators/componentManifest/getImports.js +16 -0
- package/dist/generators/componentManifest/getInputs.d.ts +23 -0
- package/dist/generators/componentManifest/getInputs.js +66 -0
- package/dist/generators/componentManifest/helpers.d.ts +5 -0
- package/dist/generators/componentManifest/helpers.js +11 -0
- package/dist/generators/componentManifest/index.d.ts +15 -0
- package/dist/generators/componentManifest/index.js +78 -0
- package/dist/generators/componentManifest/removeComponentManifest.d.ts +6 -0
- package/dist/generators/componentManifest/removeComponentManifest.js +19 -0
- package/dist/generators/componentManifest/templates/README.md.ejs +186 -0
- package/dist/generators/componentManifest/templates/actions/action.ts.ejs +14 -0
- package/dist/generators/componentManifest/templates/actions/index.ts.ejs +1 -0
- package/dist/generators/componentManifest/templates/connections/connection.ts.ejs +14 -0
- package/dist/generators/componentManifest/templates/connections/index.ts.ejs +1 -0
- package/dist/generators/componentManifest/templates/dataSources/dataSource.ts.ejs +14 -0
- package/dist/generators/componentManifest/templates/dataSources/index.ts.ejs +1 -0
- package/dist/generators/componentManifest/templates/index.ts.ejs +20 -0
- package/dist/generators/componentManifest/templates/package.json.ejs +23 -0
- package/dist/generators/componentManifest/templates/partials/importBarrel.ejs +9 -0
- package/dist/generators/componentManifest/templates/partials/imports.ejs +1 -0
- package/dist/generators/componentManifest/templates/partials/inputTypes.ejs +10 -0
- package/dist/generators/componentManifest/templates/triggers/index.ts.ejs +1 -0
- package/dist/generators/componentManifest/templates/triggers/trigger.ts.ejs +14 -0
- package/dist/generators/componentManifest/templates/tsconfig.json.ejs +15 -0
- package/dist/generators/utils/capitalizeFirstLetter.d.ts +1 -0
- package/dist/generators/utils/capitalizeFirstLetter.js +5 -0
- package/dist/generators/utils/createDependencyImports.d.ts +5 -0
- package/dist/generators/utils/createDependencyImports.js +9 -0
- package/dist/generators/utils/createFlagHelpText.d.ts +12 -0
- package/dist/generators/utils/createFlagHelpText.js +19 -0
- package/dist/generators/utils/createTemplate.d.ts +9 -0
- package/dist/generators/utils/createTemplate.js +59 -0
- package/dist/generators/utils/generatePackageJsonVersion.d.ts +1 -0
- package/dist/generators/utils/generatePackageJsonVersion.js +14 -0
- package/dist/generators/utils/getComponentSignatureWithPrism.d.ts +1 -0
- package/dist/generators/utils/getComponentSignatureWithPrism.js +41 -0
- package/dist/generators/utils/getFlagBooleanValue.d.ts +11 -0
- package/dist/generators/utils/getFlagBooleanValue.js +17 -0
- package/dist/generators/utils/getFlagStringValue.d.ts +11 -0
- package/dist/generators/utils/getFlagStringValue.js +25 -0
- package/dist/generators/utils/truncatePathByFolder.d.ts +1 -0
- package/dist/generators/utils/truncatePathByFolder.js +5 -0
- package/dist/index.d.ts +14 -15
- package/dist/index.js +9 -9
- package/dist/serverTypes/convertIntegration.d.ts +2 -2
- package/dist/serverTypes/convertIntegration.js +83 -36
- package/dist/serverTypes/index.d.ts +3 -2
- package/dist/serverTypes/integration.d.ts +10 -2
- package/dist/testing.d.ts +7 -7
- package/dist/testing.js +1 -1
- package/dist/types/ActionDefinition.d.ts +2 -1
- package/dist/types/ActionPerformFunction.d.ts +5 -3
- package/dist/types/ComponentManifest.d.ts +13 -0
- package/dist/types/ComponentManifest.js +2 -0
- package/dist/types/IntegrationDefinition.d.ts +129 -70
- package/dist/types/IntegrationDefinition.js +4 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.js +17 -10
- package/package.json +12 -6
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# <%= helpers.capitalizeFirstLetter(component.label) %> Manifest
|
|
2
|
+
|
|
3
|
+
<%= component.description %>
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This package contains the Component Manifest for the **<%= component.label %>** Component.
|
|
8
|
+
|
|
9
|
+
## Code Native Integration (CNI) Usage
|
|
10
|
+
|
|
11
|
+
### Register your component manifest in the Code Native Integration (CNI) component registry `src/componentRegistry.ts`.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { componentManifests } from "@prismatic-io/spectral";
|
|
15
|
+
import <%= component.key %> from "<%= packageName %>";
|
|
16
|
+
|
|
17
|
+
export const componentRegistry = componentManifests({
|
|
18
|
+
<%= component.key %>,
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
<% if (component.trigger) { -%>
|
|
23
|
+
### Using Triggers in flows
|
|
24
|
+
|
|
25
|
+
**Example:**
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { flow } from "@prismatic-io/spectral";
|
|
29
|
+
|
|
30
|
+
export default flow({
|
|
31
|
+
name: "Flow Name",
|
|
32
|
+
...
|
|
33
|
+
onTrigger: {
|
|
34
|
+
key: "<%= component.trigger.key %>",
|
|
35
|
+
component: "<%= component.key %>",
|
|
36
|
+
isPublic: <%= component.isPublic %>,
|
|
37
|
+
values: {
|
|
38
|
+
...
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
<% } -%>
|
|
44
|
+
|
|
45
|
+
<% if (component.action) { -%>
|
|
46
|
+
### Using Actions in flows
|
|
47
|
+
|
|
48
|
+
The component registry is accessible on the `context` argument in the `onExecution` and `onTrigger` methods as `context.components`.
|
|
49
|
+
|
|
50
|
+
**Example:**
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { flow } from "@prismatic-io/spectral";
|
|
54
|
+
|
|
55
|
+
export default flow({
|
|
56
|
+
name: "Flow Name",
|
|
57
|
+
...
|
|
58
|
+
onExecution: async (context, params) => {
|
|
59
|
+
const { components, logger, components } = context;
|
|
60
|
+
|
|
61
|
+
const response = await components.<%= component.key %>.<%= component.action.key %>({
|
|
62
|
+
...
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return Promise.resolve({ data: response });
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
<% } -%>
|
|
70
|
+
|
|
71
|
+
<% if (component.dataSource) { -%>
|
|
72
|
+
### Using Data Sources in config pages
|
|
73
|
+
|
|
74
|
+
**Example:**
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { configPage, dataSourceConfigVar } from "@prismatic-io/spectral";
|
|
78
|
+
|
|
79
|
+
export const configPages = {
|
|
80
|
+
"Data Sources": configPage({
|
|
81
|
+
elements: {
|
|
82
|
+
"Custom Data Source": dataSourceConfigVar({
|
|
83
|
+
dataType: "<%= component.dataSource.type %>",
|
|
84
|
+
stableKey: "custom-data-source",
|
|
85
|
+
dataSource: {
|
|
86
|
+
key: "<%= component.dataSource.key %>",
|
|
87
|
+
component: "<%= component.key %>",
|
|
88
|
+
isPublic: <%= component.isPublic %>,
|
|
89
|
+
values: {
|
|
90
|
+
...
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
97
|
+
```
|
|
98
|
+
<% } -%>
|
|
99
|
+
|
|
100
|
+
<% if (component.connection) { -%>
|
|
101
|
+
### Using Connections in config pages
|
|
102
|
+
|
|
103
|
+
**Example:**
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { configPage, connectionConfigVar } from "@prismatic-io/spectral";
|
|
107
|
+
|
|
108
|
+
export const configPages = {
|
|
109
|
+
Connections: configPage({
|
|
110
|
+
elements: {
|
|
111
|
+
"Custom Connection": connectionConfigVar({
|
|
112
|
+
dataType: "connection",
|
|
113
|
+
stableKey: "custom-connection"
|
|
114
|
+
connection: {
|
|
115
|
+
key: "<%= component.connection.key %>",
|
|
116
|
+
component: "<%= component.key %>",
|
|
117
|
+
isPublic: <%= component.isPublic %>,
|
|
118
|
+
values: {
|
|
119
|
+
...
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
}),
|
|
124
|
+
};
|
|
125
|
+
```
|
|
126
|
+
<% } -%>
|
|
127
|
+
|
|
128
|
+
## Development
|
|
129
|
+
|
|
130
|
+
There are two modes for this package:
|
|
131
|
+
|
|
132
|
+
1. **Component Manifest development package:** Use this to test the Component in the Code Native Integration (CNI) locally. Publishing the CNI with this package will fail because the Component doesn't exist in the Prismatic Platform yet. A development package is typically built with `npm run generate:manifest:dev` and identified by a `null` `signature` in the Component Manifest `index.ts` file.
|
|
133
|
+
|
|
134
|
+
2. **Component Manifest production package:** Use this with the Code Native Integration (CNI) either locally or in production by publishing the CNI to the Prismatic Platform. A production package is generated by publishing the Component with `prism components:publish` command, and then generating the Component Manifest with the `generate:manifest` command. A production package is identified by a non-null `signature` in the Component Manifest `index.ts` file.
|
|
135
|
+
|
|
136
|
+
### Installation with a Code Native Integration
|
|
137
|
+
|
|
138
|
+
**Before publishing the CNI, the local Component package must be published to the Prismatic Platform. This generates a stable signature key for the Component Manifest, indicating it's available for use.**
|
|
139
|
+
|
|
140
|
+
### Install via remote registry
|
|
141
|
+
|
|
142
|
+
**For public components:**
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npm install <%= packageName %>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**For private components:**
|
|
149
|
+
|
|
150
|
+
- If you're installing from a private registry, install the `<%= packageName %>` however you normally install your packages from your own registry.
|
|
151
|
+
|
|
152
|
+
**Alternatively, install from a local package or tarball.**
|
|
153
|
+
|
|
154
|
+
### Link to local package
|
|
155
|
+
|
|
156
|
+
**Things to keep in mind when using `npm link`:**
|
|
157
|
+
|
|
158
|
+
- The node versions between the Component Manifest directory and the CNI directory must be the same.
|
|
159
|
+
|
|
160
|
+
**Steps:**
|
|
161
|
+
|
|
162
|
+
1. From the new `<%= packageName %>` directory, create a symlink to the global module directory:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
npm link;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
2. From the Code Native Integration directory, link the local package:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npm link <%= packageName %>;
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Install from local tarball package
|
|
175
|
+
|
|
176
|
+
1. From the new `<%= packageName %>` directory, create a tarball package:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
npm pack;
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
2. From the Code Native Integration directory, install the tarball package:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npm install [path to tarball];
|
|
186
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%- include('../partials/imports.ejs', { imports, helpers }) -%>
|
|
2
|
+
|
|
3
|
+
export interface <%= helpers.capitalizeFirstLetter(action.key) %>Values {
|
|
4
|
+
<%- include('../partials/inputTypes.ejs', { inputs: action.inputs }) -%>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* <%= action.label %>
|
|
9
|
+
*
|
|
10
|
+
* @description <%= action.description %>
|
|
11
|
+
*/
|
|
12
|
+
export const <%= action.key %> = <TReturn>(
|
|
13
|
+
_values: <%= helpers.capitalizeFirstLetter(action.key) %>Values
|
|
14
|
+
): Promise<TReturn> => Promise.resolve<TReturn>({} as TReturn);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%- include('../partials/importBarrel.ejs', { imports: actions }) -%>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%- include('../partials/imports.ejs', { imports, helpers }) -%>
|
|
2
|
+
|
|
3
|
+
export interface <%= helpers.capitalizeFirstLetter(connection.key) %>Values {
|
|
4
|
+
<%- include('../partials/inputTypes.ejs', { inputs: connection.inputs }) -%>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* <%= connection.label %>
|
|
9
|
+
*
|
|
10
|
+
* @comments <%= connection.comments %>
|
|
11
|
+
*/
|
|
12
|
+
export const <%= connection.key %> = <TReturn>(
|
|
13
|
+
_values: <%= helpers.capitalizeFirstLetter(connection.key) %>Values
|
|
14
|
+
): Promise<TReturn> => Promise.resolve<TReturn>({} as TReturn);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%- include('../partials/importBarrel.ejs', { imports: connections }) -%>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%- include('../partials/imports.ejs', { imports, helpers }) -%>
|
|
2
|
+
|
|
3
|
+
export interface <%= helpers.capitalizeFirstLetter(dataSource.key) %>Values {
|
|
4
|
+
<%- include('../partials/inputTypes.ejs', { inputs: dataSource.inputs }) -%>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* <%= dataSource.label %>
|
|
9
|
+
*
|
|
10
|
+
* @description <%= dataSource.description %>
|
|
11
|
+
*/
|
|
12
|
+
export const <%= dataSource.key %> = <TReturn>(
|
|
13
|
+
_values: <%= helpers.capitalizeFirstLetter(dataSource.key) %>Values
|
|
14
|
+
): Promise<TReturn> => Promise.resolve<TReturn>({} as TReturn);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%- include('../partials/importBarrel.ejs', { imports: dataSources }) -%>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import actions from "./actions";
|
|
2
|
+
import connections from "./connections";
|
|
3
|
+
import dataSources from "./dataSources";
|
|
4
|
+
import triggers from "./triggers";
|
|
5
|
+
|
|
6
|
+
export { actions, connections, dataSources, triggers };
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
key: "<%= component.key %>",
|
|
10
|
+
public: <%= component.public %>,
|
|
11
|
+
<%_ if (component.signature) { -%>
|
|
12
|
+
signature: "<%= component.signature %>",
|
|
13
|
+
<%_ } else { -%>
|
|
14
|
+
signature: null,
|
|
15
|
+
<%_ } -%>
|
|
16
|
+
actions,
|
|
17
|
+
dataSources,
|
|
18
|
+
connections,
|
|
19
|
+
triggers,
|
|
20
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= packageName %>",
|
|
3
|
+
"version": "<%= helpers.generatePackageJsonVersion() %>",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"clean": "rm -rf dist",
|
|
7
|
+
"build": "npm run clean && tsc",
|
|
8
|
+
"prepare": "npm run build"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/"
|
|
12
|
+
],
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@prismatic-io/spectral": "<%= spectralVersion %>",
|
|
15
|
+
"typescript": "<%= typescriptVersion %>"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@prismatic-io/spectral": ">= <%= spectralVersion %>"
|
|
19
|
+
}<% if (registry) { %>,
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"registry": "<%= registry %>"
|
|
22
|
+
}<% } %>
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%- helpers.createDependencyImports({ imports }) -%>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<% inputs.forEach((input) => { -%>
|
|
2
|
+
/**
|
|
3
|
+
* <%= input.label %>
|
|
4
|
+
*
|
|
5
|
+
<%_ input.properties.forEach((property) => { -%>
|
|
6
|
+
* @<%= property.key %> <%- property.value %>
|
|
7
|
+
<%_ }); -%>
|
|
8
|
+
*/
|
|
9
|
+
<%= input.key %><%= input.required ? "" : "?" %>: <%- input.type.type ? input.type.type : input.type %>;
|
|
10
|
+
<% }); -%>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%- include('../partials/importBarrel.ejs', { imports: triggers }) -%>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%- include('../partials/imports.ejs', { imports, helpers }) -%>
|
|
2
|
+
|
|
3
|
+
export interface <%= helpers.capitalizeFirstLetter(trigger.key) %>Values {
|
|
4
|
+
<%- include('../partials/inputTypes.ejs', { inputs: trigger.inputs }) -%>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* <%= trigger.label %>
|
|
9
|
+
*
|
|
10
|
+
* @description <%= trigger.description %>
|
|
11
|
+
*/
|
|
12
|
+
export const <%= trigger.key %> = <TReturn>(
|
|
13
|
+
_values: <%= helpers.capitalizeFirstLetter(trigger.key) %>Values
|
|
14
|
+
): Promise<TReturn> => Promise.resolve<TReturn>({} as TReturn);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es6",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["esnext", "DOM"],
|
|
6
|
+
"strict": true,
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"outDir": "dist",
|
|
12
|
+
"skipLibCheck": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src"],
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const capitalizeFirstLetter: (value: string) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.capitalizeFirstLetter = void 0;
|
|
4
|
+
const capitalizeFirstLetter = (value) => value ? value.charAt(0).toUpperCase() + value.slice(1) : value;
|
|
5
|
+
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDependencyImports = void 0;
|
|
4
|
+
const createDependencyImports = ({ imports, }) => {
|
|
5
|
+
return Object.entries(imports).map(([module, types]) => {
|
|
6
|
+
return `import type { ${types.join(", ")} } from "${module}";`;
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
exports.createDependencyImports = createDependencyImports;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface CreateFlagHelpTextProps {
|
|
2
|
+
flags: {
|
|
3
|
+
[key: string]: {
|
|
4
|
+
flag: string[];
|
|
5
|
+
description: string;
|
|
6
|
+
value: string | boolean | null;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
command: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const createFlagHelpText: ({ flags, command, }: CreateFlagHelpTextProps) => void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFlagHelpText = void 0;
|
|
4
|
+
const createFlagHelpText = ({ flags, command, }) => {
|
|
5
|
+
console.log(`Usage: ${command} [options]\n`);
|
|
6
|
+
console.log("Options:");
|
|
7
|
+
let longestFlag = 0;
|
|
8
|
+
const formattedFlags = Object.values(flags).map(({ flag: flagBase, description }) => {
|
|
9
|
+
const flag = flagBase.join(", ");
|
|
10
|
+
if (flag.length > longestFlag) {
|
|
11
|
+
longestFlag = flag.length;
|
|
12
|
+
}
|
|
13
|
+
return { flag, description };
|
|
14
|
+
});
|
|
15
|
+
formattedFlags.forEach(({ flag, description }) => {
|
|
16
|
+
console.log(` ${flag.padEnd(longestFlag + 2)} ${description}`);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.createFlagHelpText = createFlagHelpText;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface CreateTemplateProps {
|
|
2
|
+
source: string;
|
|
3
|
+
destination?: string;
|
|
4
|
+
data?: Record<string, unknown>;
|
|
5
|
+
dryRun: boolean;
|
|
6
|
+
verbose: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const createTemplate: ({ source, destination, data, dryRun, verbose, }: CreateTemplateProps) => Promise<string | void>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createTemplate = void 0;
|
|
16
|
+
const ejs_1 = require("ejs");
|
|
17
|
+
const fs_extra_1 = require("fs-extra");
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const createTemplate = ({ source, destination = source.replace(/\.ejs$/, ""), data = {}, dryRun, verbose, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
if (!source) {
|
|
21
|
+
throw new Error("Source is required");
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
if (path_1.default.extname(source) === ".ejs") {
|
|
25
|
+
const rendered = yield (0, ejs_1.renderFile)(source, data);
|
|
26
|
+
if (dryRun) {
|
|
27
|
+
console.info("");
|
|
28
|
+
console.info("");
|
|
29
|
+
console.info(`Rendering ${source} to ${destination}`);
|
|
30
|
+
console.info("---------------------------- Start ----------------------------");
|
|
31
|
+
console.info(rendered);
|
|
32
|
+
console.info("---------------------------- End ----------------------------");
|
|
33
|
+
console.info("");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (verbose) {
|
|
37
|
+
console.info(`Rendering ${source} to ${destination}`);
|
|
38
|
+
}
|
|
39
|
+
yield (0, fs_extra_1.outputFile)(destination, rendered, { encoding: "utf-8" });
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
if (dryRun) {
|
|
43
|
+
console.info("");
|
|
44
|
+
console.info(`Copying ${source} to ${destination}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (verbose) {
|
|
48
|
+
console.info(`Copying ${source} to ${destination}`);
|
|
49
|
+
}
|
|
50
|
+
yield (0, fs_extra_1.mkdirp)(path_1.default.dirname(destination));
|
|
51
|
+
yield (0, fs_extra_1.copyFile)(source, destination);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
console.error(err);
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
exports.createTemplate = createTemplate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generatePackageJsonVersion: () => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePackageJsonVersion = void 0;
|
|
4
|
+
const generatePackageJsonVersion = () => {
|
|
5
|
+
const now = new Date();
|
|
6
|
+
const year = now.getUTCFullYear();
|
|
7
|
+
const month = String(now.getUTCMonth() + 1);
|
|
8
|
+
const day = String(now.getUTCDate());
|
|
9
|
+
const hours = String(now.getUTCHours());
|
|
10
|
+
const minutes = String(now.getUTCMinutes());
|
|
11
|
+
const seconds = String(now.getUTCSeconds());
|
|
12
|
+
return `${year}.${month}.${day}-t-${hours}.${minutes}.${seconds}`;
|
|
13
|
+
};
|
|
14
|
+
exports.generatePackageJsonVersion = generatePackageJsonVersion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getComponentSignatureWithPrism: () => Promise<string | null>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getComponentSignatureWithPrism = void 0;
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const util_1 = require("util");
|
|
15
|
+
const exec = (0, util_1.promisify)(child_process_1.exec);
|
|
16
|
+
const getComponentSignatureWithPrism = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
if (!(yield isPrismAvailable())) {
|
|
18
|
+
console.log("Prism must be installed");
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const { stdout: signatureKey } = yield exec("prism components:signature", {
|
|
22
|
+
windowsHide: true,
|
|
23
|
+
});
|
|
24
|
+
if (!signatureKey) {
|
|
25
|
+
console.log("Failed to get component signature. Please verify your Component has been published.");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
return signatureKey.replace(/\n$/, "");
|
|
29
|
+
});
|
|
30
|
+
exports.getComponentSignatureWithPrism = getComponentSignatureWithPrism;
|
|
31
|
+
const isPrismAvailable = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
try {
|
|
33
|
+
yield exec("prism --version", {
|
|
34
|
+
windowsHide: true,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (_a) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface GetFlagBooleanValueProps {
|
|
2
|
+
args: string[];
|
|
3
|
+
flag: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const getFlagBooleanValue: ({ args, flag, }: GetFlagBooleanValueProps) => boolean;
|
|
6
|
+
interface GetFlagsBooleanValueProps {
|
|
7
|
+
args: string[];
|
|
8
|
+
flags: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare const getFlagsBooleanValue: ({ args, flags, }: GetFlagsBooleanValueProps) => boolean;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFlagsBooleanValue = exports.getFlagBooleanValue = void 0;
|
|
4
|
+
const getFlagBooleanValue = ({ args, flag, }) => {
|
|
5
|
+
return args.includes(flag);
|
|
6
|
+
};
|
|
7
|
+
exports.getFlagBooleanValue = getFlagBooleanValue;
|
|
8
|
+
const getFlagsBooleanValue = ({ args, flags, }) => {
|
|
9
|
+
return flags.reduce((acc, flag) => {
|
|
10
|
+
const value = (0, exports.getFlagBooleanValue)({ args, flag });
|
|
11
|
+
if (typeof value === "undefined" || acc) {
|
|
12
|
+
return acc;
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}, false);
|
|
16
|
+
};
|
|
17
|
+
exports.getFlagsBooleanValue = getFlagsBooleanValue;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface GetFlagStringValueProps {
|
|
2
|
+
args: string[];
|
|
3
|
+
flag: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const getFlagStringValue: ({ args, flag, }: GetFlagStringValueProps) => string | null;
|
|
6
|
+
interface GetFlagsStringValueProps {
|
|
7
|
+
args: string[];
|
|
8
|
+
flags: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare const getFlagsStringValue: ({ args, flags, }: GetFlagsStringValueProps) => string | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFlagsStringValue = exports.getFlagStringValue = void 0;
|
|
4
|
+
const getFlagStringValue = ({ args, flag, }) => {
|
|
5
|
+
const flagIndex = args.indexOf(flag);
|
|
6
|
+
if (flagIndex === -1) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const flagValue = args[flagIndex + 1];
|
|
10
|
+
if (!flagValue || flagValue.startsWith("--")) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return flagValue.replace(/(^"|"$)|(^'|'$)/g, "");
|
|
14
|
+
};
|
|
15
|
+
exports.getFlagStringValue = getFlagStringValue;
|
|
16
|
+
const getFlagsStringValue = ({ args, flags, }) => {
|
|
17
|
+
return flags.reduce((acc, flag) => {
|
|
18
|
+
const value = (0, exports.getFlagStringValue)({ args, flag });
|
|
19
|
+
if (typeof value === "undefined" || acc) {
|
|
20
|
+
return acc;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}, "");
|
|
24
|
+
};
|
|
25
|
+
exports.getFlagsStringValue = getFlagsStringValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const truncatePathByFolder: (path: string, folder: string) => string;
|