@wix/astro 1.0.6 → 1.0.7
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/build/index.js +5970 -10151
- package/build/index.js.map +1 -1
- package/package.json +4 -7
- package/src/directories.ts +2 -13
- package/src/index.ts +35 -46
- package/src/schemas.ts +204 -0
- package/src/types.ts +19 -0
- package/src/utils/createProjectModel.ts +71 -91
- package/src/utils/fs-utils.ts +37 -0
- package/src/utils/generateAppManifest.ts +161 -111
- package/src/utils/isValidBackofficeComponent.ts +5 -6
- package/src/utils/isValidServicePluginComponent.ts +7 -8
- package/src/utils/isValidWebhookComponent.ts +2 -4
- package/src/utils/loadEnvVars.ts +38 -0
- package/src/utils/writeVirtualBackofficeExtensionFiles.ts +6 -5
- package/src/utils/writeVirtualServicePluginExtensionFiles.ts +7 -4
- package/src/utils/writeVirtualWebhookExtensionFiles.ts +7 -4
- package/tsup.config.mjs +34 -19
- package/build/xdg-open +0 -1267
- package/build/yoga.wasm +0 -0
- package/src/utils/loadExtension.ts +0 -59
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AppManifest,
|
|
3
|
+
BackofficeExtensionMenuItem,
|
|
4
|
+
BackofficeExtensionWidget,
|
|
5
|
+
BackofficeModal,
|
|
3
6
|
BackofficePage,
|
|
4
7
|
EcomAdditionalFees,
|
|
5
8
|
EcomDiscountsTrigger,
|
|
@@ -8,132 +11,179 @@ import type {
|
|
|
8
11
|
EcomShippingRates,
|
|
9
12
|
EcomValidations,
|
|
10
13
|
Webhook,
|
|
11
|
-
} from '
|
|
12
|
-
import {
|
|
13
|
-
import type { Model } from './createProjectModel.js';
|
|
14
|
+
} from '../schemas.js';
|
|
15
|
+
import type { Model } from '../types.js';
|
|
14
16
|
|
|
15
|
-
export function generateAppManifest(model: Model)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
export function generateAppManifest(model: Model) {
|
|
18
|
+
const extensions = model.extensions
|
|
19
|
+
.map((extension) => extension.manifest)
|
|
20
|
+
.map((manifest) => {
|
|
21
|
+
switch (manifest.compType) {
|
|
22
|
+
case 'BACK_OFFICE_EXTENSION_MENU_ITEM':
|
|
23
|
+
if (manifest.compData.backOfficeExtensionMenuItem.iframeUrl) {
|
|
24
|
+
return manifest;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
...manifest,
|
|
29
|
+
compData: {
|
|
30
|
+
backOfficeExtensionMenuItem: {
|
|
31
|
+
...manifest.compData.backOfficeExtensionMenuItem,
|
|
32
|
+
iframeUrl: `_wix/extensions/backoffice/${manifest.compId}`,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
} satisfies BackofficeExtensionMenuItem;
|
|
36
|
+
case 'BACK_OFFICE_EXTENSION_WIDGET':
|
|
37
|
+
if (manifest.compData.backOfficeExtensionWidget.iframeUrl) {
|
|
38
|
+
return manifest;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
...manifest,
|
|
43
|
+
compData: {
|
|
44
|
+
backOfficeExtensionWidget: {
|
|
45
|
+
...manifest.compData.backOfficeExtensionWidget,
|
|
46
|
+
iframeUrl: `_wix/extensions/backoffice/${manifest.compId}`,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
} satisfies BackofficeExtensionWidget;
|
|
50
|
+
case 'BACK_OFFICE_MODAL':
|
|
51
|
+
if (manifest.compData.backOfficeModal.iframeUrl) {
|
|
52
|
+
return manifest;
|
|
53
|
+
}
|
|
26
54
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
55
|
+
return {
|
|
56
|
+
...manifest,
|
|
57
|
+
compData: {
|
|
58
|
+
backOfficeModal: {
|
|
59
|
+
...manifest.compData.backOfficeModal,
|
|
60
|
+
iframeUrl: `_wix/extensions/backoffice/${manifest.compId}`,
|
|
34
61
|
},
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
62
|
+
},
|
|
63
|
+
} satisfies BackofficeModal;
|
|
64
|
+
case 'BACK_OFFICE_PAGE':
|
|
65
|
+
if (manifest.compData.backOfficePage.iframeUrl) {
|
|
66
|
+
return manifest;
|
|
67
|
+
}
|
|
40
68
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
69
|
+
return {
|
|
70
|
+
...manifest,
|
|
71
|
+
compData: {
|
|
72
|
+
backOfficePage: {
|
|
73
|
+
...manifest.compData.backOfficePage,
|
|
74
|
+
iframeUrl: `_wix/extensions/backoffice/${manifest.compId}`,
|
|
48
75
|
},
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
76
|
+
},
|
|
77
|
+
} satisfies BackofficePage;
|
|
78
|
+
case 'ECOM_ADDITIONAL_FEES':
|
|
79
|
+
if (manifest.compData.ecomAdditionalFees.deploymentUri) {
|
|
80
|
+
return manifest;
|
|
81
|
+
}
|
|
54
82
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
83
|
+
return {
|
|
84
|
+
...manifest,
|
|
85
|
+
compData: {
|
|
86
|
+
ecomAdditionalFees: {
|
|
87
|
+
...manifest.compData.ecomAdditionalFees,
|
|
88
|
+
deploymentUri: `_wix/extensions/service-plugins/${manifest.compId}`,
|
|
62
89
|
},
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
},
|
|
91
|
+
} satisfies EcomAdditionalFees;
|
|
92
|
+
case 'ECOM_DISCOUNTS_TRIGGER':
|
|
93
|
+
if (manifest.compData.ecomDiscountsTrigger.deploymentUri) {
|
|
94
|
+
return manifest;
|
|
95
|
+
}
|
|
68
96
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
97
|
+
return {
|
|
98
|
+
...manifest,
|
|
99
|
+
compData: {
|
|
100
|
+
ecomDiscountsTrigger: {
|
|
101
|
+
...manifest.compData.ecomDiscountsTrigger,
|
|
102
|
+
deploymentUri: `_wix/extensions/service-plugins/${manifest.compId}`,
|
|
76
103
|
},
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
104
|
+
},
|
|
105
|
+
} satisfies EcomDiscountsTrigger;
|
|
106
|
+
case 'ECOM_PAYMENT_SETTINGS':
|
|
107
|
+
if (manifest.compData.ecomPaymentSettings.deploymentUri) {
|
|
108
|
+
return manifest;
|
|
109
|
+
}
|
|
82
110
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
},
|
|
111
|
+
return {
|
|
112
|
+
...manifest,
|
|
113
|
+
compData: {
|
|
114
|
+
ecomPaymentSettings: {
|
|
115
|
+
...manifest.compData.ecomPaymentSettings,
|
|
116
|
+
deploymentUri: `_wix/extensions/service-plugins/${manifest.compId}`,
|
|
90
117
|
},
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
118
|
+
},
|
|
119
|
+
} satisfies EcomPaymentSettings;
|
|
120
|
+
case 'ECOM_SHIPPING_RATES':
|
|
121
|
+
if (manifest.compData.ecomShippingRates.deploymentUri) {
|
|
122
|
+
return manifest;
|
|
123
|
+
}
|
|
96
124
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
},
|
|
125
|
+
return {
|
|
126
|
+
...manifest,
|
|
127
|
+
compData: {
|
|
128
|
+
ecomShippingRates: {
|
|
129
|
+
...manifest.compData.ecomShippingRates,
|
|
130
|
+
deploymentUri: `_wix/extensions/service-plugins/${manifest.compId}`,
|
|
104
131
|
},
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
},
|
|
133
|
+
} satisfies EcomShippingRates;
|
|
134
|
+
case 'ECOM_VALIDATIONS':
|
|
135
|
+
if (manifest.compData.ecomValidations.deploymentUri) {
|
|
136
|
+
return manifest;
|
|
137
|
+
}
|
|
110
138
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
},
|
|
139
|
+
return {
|
|
140
|
+
...manifest,
|
|
141
|
+
compData: {
|
|
142
|
+
ecomValidations: {
|
|
143
|
+
...manifest.compData.ecomValidations,
|
|
144
|
+
deploymentUri: `_wix/extensions/service-plugins/${manifest.compId}`,
|
|
118
145
|
},
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
146
|
+
},
|
|
147
|
+
} satisfies EcomValidations;
|
|
148
|
+
case 'GIFT_CARDS_PROVIDER':
|
|
149
|
+
if (manifest.compData.giftCardsProvider.deploymentUri) {
|
|
150
|
+
return manifest;
|
|
151
|
+
}
|
|
124
152
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
153
|
+
return {
|
|
154
|
+
...manifest,
|
|
155
|
+
compData: {
|
|
156
|
+
giftCardsProvider: {
|
|
157
|
+
...manifest.compData.giftCardsProvider,
|
|
158
|
+
deploymentUri: `_wix/extensions/service-plugins/${manifest.compId}`,
|
|
132
159
|
},
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
160
|
+
},
|
|
161
|
+
} satisfies EcomGiftCardsProvider;
|
|
162
|
+
case 'WEBHOOK':
|
|
163
|
+
if (manifest.compData.webhook.callbackUrl) {
|
|
164
|
+
return manifest;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
...manifest,
|
|
169
|
+
compData: {
|
|
170
|
+
webhook: {
|
|
171
|
+
...manifest.compData.webhook,
|
|
172
|
+
callbackUrl: `_wix/extensions/webhooks/${manifest.compId}`,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
} satisfies Webhook;
|
|
176
|
+
default:
|
|
177
|
+
return manifest;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const unknownExtensions = model.unknownExtensions.map(
|
|
182
|
+
(extension) => extension.manifest
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
appId: model.appId,
|
|
187
|
+
components: [...extensions, ...unknownExtensions],
|
|
188
|
+
} satisfies AppManifest;
|
|
139
189
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import type { Component } from '
|
|
2
|
-
import { ComponentType } from '@wix/ambassador-devcenter-components-v1-component/types';
|
|
1
|
+
import type { Component } from '../schemas.js';
|
|
3
2
|
|
|
4
3
|
export function isValidBackofficeComponent(component: Component) {
|
|
5
4
|
return (
|
|
6
|
-
(component.compType ===
|
|
5
|
+
(component.compType === 'BACK_OFFICE_PAGE' &&
|
|
7
6
|
!component.compData.backOfficePage.iframeUrl) ||
|
|
8
|
-
(component.compType ===
|
|
7
|
+
(component.compType === 'BACK_OFFICE_EXTENSION_WIDGET' &&
|
|
9
8
|
!component.compData.backOfficeExtensionWidget.iframeUrl) ||
|
|
10
|
-
(component.compType ===
|
|
9
|
+
(component.compType === 'BACK_OFFICE_EXTENSION_MENU_ITEM' &&
|
|
11
10
|
!component.compData.backOfficeExtensionMenuItem.iframeUrl) ||
|
|
12
|
-
(component.compType ===
|
|
11
|
+
(component.compType === 'BACK_OFFICE_MODAL' &&
|
|
13
12
|
!component.compData.backOfficeModal.iframeUrl)
|
|
14
13
|
);
|
|
15
14
|
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import type { Component } from '
|
|
2
|
-
import { ComponentType } from '@wix/ambassador-devcenter-components-v1-component/types';
|
|
1
|
+
import type { Component } from '../schemas.js';
|
|
3
2
|
|
|
4
3
|
export function isValidServicePluginComponent(component: Component) {
|
|
5
4
|
return (
|
|
6
|
-
(component.compType ===
|
|
5
|
+
(component.compType === 'ECOM_SHIPPING_RATES' &&
|
|
7
6
|
!component.compData.ecomShippingRates.deploymentUri) ||
|
|
8
|
-
(component.compType ===
|
|
7
|
+
(component.compType === 'ECOM_ADDITIONAL_FEES' &&
|
|
9
8
|
!component.compData.ecomAdditionalFees.deploymentUri) ||
|
|
10
|
-
(component.compType ===
|
|
9
|
+
(component.compType === 'ECOM_DISCOUNTS_TRIGGER' &&
|
|
11
10
|
!component.compData.ecomDiscountsTrigger.deploymentUri) ||
|
|
12
|
-
(component.compType ===
|
|
11
|
+
(component.compType === 'ECOM_VALIDATIONS' &&
|
|
13
12
|
!component.compData.ecomValidations.deploymentUri) ||
|
|
14
|
-
(component.compType ===
|
|
13
|
+
(component.compType === 'ECOM_PAYMENT_SETTINGS' &&
|
|
15
14
|
!component.compData.ecomPaymentSettings.deploymentUri) ||
|
|
16
|
-
(component.compType ===
|
|
15
|
+
(component.compType === 'GIFT_CARDS_PROVIDER' &&
|
|
17
16
|
!component.compData.giftCardsProvider.deploymentUri)
|
|
18
17
|
);
|
|
19
18
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { Component } from '
|
|
2
|
-
import { ComponentType } from '@wix/ambassador-devcenter-components-v1-component/types';
|
|
1
|
+
import type { Component } from '../schemas.js';
|
|
3
2
|
|
|
4
3
|
export function isValidWebhookComponent(component: Component) {
|
|
5
4
|
return (
|
|
6
|
-
component.compType ===
|
|
7
|
-
!component.compData.webhook.callbackUrl
|
|
5
|
+
component.compType === 'WEBHOOK' && !component.compData.webhook.callbackUrl
|
|
8
6
|
);
|
|
9
7
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AstroIntegrationLogger } from 'astro';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { outdent } from 'outdent';
|
|
4
|
+
import { loadEnv } from 'vite';
|
|
5
|
+
|
|
6
|
+
const wixClientIdEnvVar = 'WIX_CLIENT_ID';
|
|
7
|
+
|
|
8
|
+
export function loadEnvVars(rootDir: string, logger: AstroIntegrationLogger) {
|
|
9
|
+
const env = loadEnv(process.env.NODE_ENV ?? 'development', process.cwd(), '');
|
|
10
|
+
const appId = env[wixClientIdEnvVar];
|
|
11
|
+
|
|
12
|
+
if (!appId) {
|
|
13
|
+
logger.error(
|
|
14
|
+
outdent`
|
|
15
|
+
Missing environment variable ${chalk.blueBright(wixClientIdEnvVar)}
|
|
16
|
+
To use the Wix SDK, you must provide the ${chalk.blueBright(
|
|
17
|
+
wixClientIdEnvVar
|
|
18
|
+
)} environment variable.
|
|
19
|
+
💡 To pull the required environment variables from Wix, run:
|
|
20
|
+
${chalk.magenta('npx wix edge env --env local pull')}
|
|
21
|
+
🔍 Need Help?
|
|
22
|
+
- Visit our docs: https://dev.wix.com/docs/go-headless
|
|
23
|
+
- Join the community: https://discord.com/channels/1114269395317968906/1288424190969511987
|
|
24
|
+
`
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
throw new Error(
|
|
28
|
+
`${chalk.magenta(
|
|
29
|
+
wixClientIdEnvVar
|
|
30
|
+
)} not found in loaded environment variables`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
appId,
|
|
36
|
+
env,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -2,7 +2,7 @@ import { rm, writeFile } from 'node:fs/promises';
|
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { globby } from 'globby';
|
|
4
4
|
import { outdent } from 'outdent';
|
|
5
|
-
import type { Model } from '../
|
|
5
|
+
import type { Model } from '../types.js';
|
|
6
6
|
import { isValidBackofficeComponent } from '../utils/isValidBackofficeComponent.js';
|
|
7
7
|
|
|
8
8
|
export async function writeVirtualBackofficeExtensionFiles(
|
|
@@ -10,7 +10,7 @@ export async function writeVirtualBackofficeExtensionFiles(
|
|
|
10
10
|
codegenDir: string
|
|
11
11
|
) {
|
|
12
12
|
const backofficeExtensions = model.extensions.filter((extension) =>
|
|
13
|
-
isValidBackofficeComponent(extension.
|
|
13
|
+
isValidBackofficeComponent(extension.manifest)
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
const existingFiles = await globby(`*.astro`, {
|
|
@@ -20,7 +20,7 @@ export async function writeVirtualBackofficeExtensionFiles(
|
|
|
20
20
|
|
|
21
21
|
for (const filename of existingFiles) {
|
|
22
22
|
const hasMatchingSourceFile = backofficeExtensions.some(
|
|
23
|
-
(extension) => `${extension.
|
|
23
|
+
(extension) => `${extension.manifest.compId}.astro` === filename
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
if (hasMatchingSourceFile) {
|
|
@@ -33,11 +33,12 @@ export async function writeVirtualBackofficeExtensionFiles(
|
|
|
33
33
|
for (const extension of backofficeExtensions) {
|
|
34
34
|
const originalEntrypoint = resolve(
|
|
35
35
|
model.rootDir,
|
|
36
|
-
extension.
|
|
36
|
+
extension.cwd,
|
|
37
|
+
'page.tsx'
|
|
37
38
|
);
|
|
38
39
|
const virtualEntrypoint = join(
|
|
39
40
|
codegenDir,
|
|
40
|
-
`${extension.
|
|
41
|
+
`${extension.manifest.compId}.astro`
|
|
41
42
|
);
|
|
42
43
|
|
|
43
44
|
await writeFile(
|
|
@@ -2,7 +2,7 @@ import { rm, writeFile } from 'node:fs/promises';
|
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { globby } from 'globby';
|
|
4
4
|
import { outdent } from 'outdent';
|
|
5
|
-
import type { Model } from '../
|
|
5
|
+
import type { Model } from '../types.js';
|
|
6
6
|
import { isValidServicePluginComponent } from './isValidServicePluginComponent.js';
|
|
7
7
|
|
|
8
8
|
export async function writeVirtualServicePluginExtensionFiles(
|
|
@@ -10,7 +10,7 @@ export async function writeVirtualServicePluginExtensionFiles(
|
|
|
10
10
|
codegenDir: string
|
|
11
11
|
) {
|
|
12
12
|
const servicePluginExtensions = model.extensions.filter((extension) =>
|
|
13
|
-
isValidServicePluginComponent(extension.
|
|
13
|
+
isValidServicePluginComponent(extension.manifest)
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
const existingFiles = await globby(`*.ts`, {
|
|
@@ -20,7 +20,7 @@ export async function writeVirtualServicePluginExtensionFiles(
|
|
|
20
20
|
|
|
21
21
|
for (const filename of existingFiles) {
|
|
22
22
|
const hasMatchingSourceFile = servicePluginExtensions.some(
|
|
23
|
-
(extension) => `${extension.
|
|
23
|
+
(extension) => `${extension.manifest.compId}.ts` === filename
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
if (hasMatchingSourceFile) {
|
|
@@ -32,7 +32,10 @@ export async function writeVirtualServicePluginExtensionFiles(
|
|
|
32
32
|
|
|
33
33
|
for (const extension of servicePluginExtensions) {
|
|
34
34
|
const originalEntrypoint = resolve(extension.cwd, 'plugin.ts');
|
|
35
|
-
const virtualEntrypoint = join(
|
|
35
|
+
const virtualEntrypoint = join(
|
|
36
|
+
codegenDir,
|
|
37
|
+
`${extension.manifest.compId}.ts`
|
|
38
|
+
);
|
|
36
39
|
|
|
37
40
|
await writeFile(
|
|
38
41
|
virtualEntrypoint,
|
|
@@ -2,7 +2,7 @@ import { rm, writeFile } from 'node:fs/promises';
|
|
|
2
2
|
import { join, resolve } from 'node:path';
|
|
3
3
|
import { globby } from 'globby';
|
|
4
4
|
import { outdent } from 'outdent';
|
|
5
|
-
import type { Model } from '../
|
|
5
|
+
import type { Model } from '../types.js';
|
|
6
6
|
import { isValidWebhookComponent } from './isValidWebhookComponent.js';
|
|
7
7
|
|
|
8
8
|
export async function writeVirtualWebhookExtensionFiles(
|
|
@@ -10,7 +10,7 @@ export async function writeVirtualWebhookExtensionFiles(
|
|
|
10
10
|
codegenDir: string
|
|
11
11
|
) {
|
|
12
12
|
const webhookExtensions = model.extensions.filter((extension) =>
|
|
13
|
-
isValidWebhookComponent(extension.
|
|
13
|
+
isValidWebhookComponent(extension.manifest)
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
const existingFiles = await globby(`*.ts`, {
|
|
@@ -20,7 +20,7 @@ export async function writeVirtualWebhookExtensionFiles(
|
|
|
20
20
|
|
|
21
21
|
for (const filename of existingFiles) {
|
|
22
22
|
const hasMatchingSourceFile = webhookExtensions.some(
|
|
23
|
-
(extension) => `${extension.
|
|
23
|
+
(extension) => `${extension.manifest.compId}.ts` === filename
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
if (hasMatchingSourceFile) {
|
|
@@ -32,7 +32,10 @@ export async function writeVirtualWebhookExtensionFiles(
|
|
|
32
32
|
|
|
33
33
|
for (const extension of webhookExtensions) {
|
|
34
34
|
const originalEntrypoint = resolve(extension.cwd, 'event.ts');
|
|
35
|
-
const virtualEntrypoint = join(
|
|
35
|
+
const virtualEntrypoint = join(
|
|
36
|
+
codegenDir,
|
|
37
|
+
`${extension.manifest.compId}.ts`
|
|
38
|
+
);
|
|
36
39
|
|
|
37
40
|
await writeFile(
|
|
38
41
|
virtualEntrypoint,
|
package/tsup.config.mjs
CHANGED
|
@@ -1,32 +1,47 @@
|
|
|
1
|
-
import
|
|
1
|
+
import isCI from 'is-ci';
|
|
2
|
+
import { outdent } from 'outdent';
|
|
3
|
+
import { defineConfig } from 'tsup';
|
|
2
4
|
|
|
3
|
-
export default defineConfig(
|
|
5
|
+
export default defineConfig([
|
|
4
6
|
{
|
|
5
7
|
entry: ['src/index.ts'],
|
|
6
8
|
target: 'node20.9',
|
|
7
9
|
format: ['esm'],
|
|
8
10
|
outDir: 'build',
|
|
9
11
|
splitting: false,
|
|
12
|
+
clean: true,
|
|
13
|
+
sourcemap: true,
|
|
10
14
|
external: ['astro', 'vite', /^astro:/],
|
|
11
15
|
dts: {
|
|
12
16
|
resolve: ['astro', 'vite', /^astro:/],
|
|
13
17
|
},
|
|
18
|
+
// We specifically do not minify the code in packages **for node** in order to keep it readable for debugging purposes.
|
|
19
|
+
minify: false,
|
|
20
|
+
env: {
|
|
21
|
+
NODE_ENV: isCI ? 'production' : 'development',
|
|
22
|
+
},
|
|
23
|
+
shims: true,
|
|
24
|
+
// https://github.com/evanw/esbuild/issues/1921
|
|
25
|
+
banner: {
|
|
26
|
+
js: outdent`
|
|
27
|
+
import { createRequire as _createRequire } from 'node:module';
|
|
28
|
+
const require = _createRequire(import.meta.url);
|
|
29
|
+
`,
|
|
30
|
+
},
|
|
14
31
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
resolve: ['astro', 'vite', /^astro:/],
|
|
29
|
-
},
|
|
32
|
+
{
|
|
33
|
+
entry: [
|
|
34
|
+
'src/middleware/auth.ts',
|
|
35
|
+
'src/routes/webhooks.ts',
|
|
36
|
+
'src/routes/service-plugins.ts',
|
|
37
|
+
],
|
|
38
|
+
target: 'node20.9',
|
|
39
|
+
format: ['esm'],
|
|
40
|
+
outDir: 'build-runtime',
|
|
41
|
+
splitting: false,
|
|
42
|
+
external: ['astro', 'vite', /^astro:/],
|
|
43
|
+
dts: {
|
|
44
|
+
resolve: ['astro', 'vite', /^astro:/],
|
|
30
45
|
},
|
|
31
|
-
|
|
32
|
-
);
|
|
46
|
+
},
|
|
47
|
+
]);
|