@superblocksteam/sdk 2.0.6-next.113 → 2.0.6-next.12
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/dist/application-build.mjs +2 -6
- package/dist/application-build.mjs.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.d.ts +2 -5
- package/dist/cli-replacement/automatic-upgrades.d.ts.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.js +49 -114
- package/dist/cli-replacement/automatic-upgrades.js.map +1 -1
- package/dist/cli-replacement/dev.d.mts +2 -1
- package/dist/cli-replacement/dev.d.mts.map +1 -1
- package/dist/cli-replacement/dev.mjs +32 -57
- package/dist/cli-replacement/dev.mjs.map +1 -1
- package/dist/client.d.ts +0 -34
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -92
- package/dist/client.js.map +1 -1
- package/dist/dev-utils/dev-logger.d.mts +7 -17
- package/dist/dev-utils/dev-logger.d.mts.map +1 -1
- package/dist/dev-utils/dev-logger.mjs +9 -50
- package/dist/dev-utils/dev-logger.mjs.map +1 -1
- package/dist/dev-utils/dev-server.d.mts.map +1 -1
- package/dist/dev-utils/dev-server.mjs +15 -8
- package/dist/dev-utils/dev-server.mjs.map +1 -1
- package/dist/dev-utils/dev-tracer.d.ts +0 -2
- package/dist/dev-utils/dev-tracer.d.ts.map +1 -1
- package/dist/dev-utils/dev-tracer.js +35 -42
- package/dist/dev-utils/dev-tracer.js.map +1 -1
- package/dist/dev-utils/vite-plugin-sb-cdn.d.mts.map +1 -1
- package/dist/dev-utils/vite-plugin-sb-cdn.mjs +3 -13
- package/dist/dev-utils/vite-plugin-sb-cdn.mjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.mjs +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.mjs.map +1 -1
- package/package.json +3 -5
- package/src/application-build.mts +3 -6
- package/src/cli-replacement/automatic-upgrades.ts +59 -158
- package/src/cli-replacement/dev.mts +43 -77
- package/src/client.ts +0 -115
- package/src/dev-utils/dev-logger.mts +20 -94
- package/src/dev-utils/dev-server.mts +15 -10
- package/src/dev-utils/dev-tracer.ts +37 -48
- package/src/dev-utils/vite-plugin-sb-cdn.mts +3 -14
- package/src/index.ts +0 -4
- package/src/vite-plugin-inject-sb-ids-transform.mts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/dev-utils/vite-plugin-build-manifest-stub.d.mts +0 -10
- package/dist/dev-utils/vite-plugin-build-manifest-stub.d.mts.map +0 -1
- package/dist/dev-utils/vite-plugin-build-manifest-stub.mjs +0 -27
- package/dist/dev-utils/vite-plugin-build-manifest-stub.mjs.map +0 -1
- package/dist/vite-plugin-generate-build-manifest.d.mts +0 -21
- package/dist/vite-plugin-generate-build-manifest.d.mts.map +0 -1
- package/dist/vite-plugin-generate-build-manifest.mjs +0 -130
- package/dist/vite-plugin-generate-build-manifest.mjs.map +0 -1
- package/src/dev-utils/vite-plugin-build-manifest-stub.mts +0 -30
- package/src/vite-plugin-generate-build-manifest.mts +0 -192
- package/test/clients.test.mts +0 -120
package/src/client.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
NotFoundError,
|
|
12
12
|
BadRequestError,
|
|
13
13
|
unreachable,
|
|
14
|
-
getSuperblocksDevEnvironmentConfigJson,
|
|
15
14
|
} from "@superblocksteam/util";
|
|
16
15
|
import axios, { AxiosError } from "axios";
|
|
17
16
|
import FormData from "form-data";
|
|
@@ -25,10 +24,6 @@ import { signingEnabled } from "./flag.js";
|
|
|
25
24
|
import { connectToISocketRPCServer } from "./socket/index.js";
|
|
26
25
|
import { AgentType } from "./types/index.js";
|
|
27
26
|
import { getAgentUrl } from "./utils.js";
|
|
28
|
-
import {
|
|
29
|
-
DEFAULT_BRANCH,
|
|
30
|
-
getCurrentGitBranchIfGit,
|
|
31
|
-
} from "./version-control.mjs";
|
|
32
27
|
import type { StdISocketRPCClient } from "./socket/index.js";
|
|
33
28
|
import type {
|
|
34
29
|
ApiWithPb,
|
|
@@ -138,116 +133,6 @@ enum ResourceType {
|
|
|
138
133
|
BACKEND = "BACKEND",
|
|
139
134
|
}
|
|
140
135
|
|
|
141
|
-
export enum BranchSource {
|
|
142
|
-
DEV_ENVIRONMENT = "dev environment config file",
|
|
143
|
-
COMMAND_LINE = "command line",
|
|
144
|
-
GIT_REPO = "current git repository",
|
|
145
|
-
DEFAULT = "default",
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export class CurrentBranch {
|
|
149
|
-
public readonly branchName: string;
|
|
150
|
-
public readonly source: BranchSource;
|
|
151
|
-
public readonly sourcePath?: string;
|
|
152
|
-
public readonly userSpecifiedBranch?: string;
|
|
153
|
-
|
|
154
|
-
constructor({
|
|
155
|
-
branchName,
|
|
156
|
-
source,
|
|
157
|
-
sourcePath,
|
|
158
|
-
userSpecifiedBranch,
|
|
159
|
-
}: {
|
|
160
|
-
branchName: string;
|
|
161
|
-
source: BranchSource;
|
|
162
|
-
sourcePath?: string;
|
|
163
|
-
userSpecifiedBranch?: string;
|
|
164
|
-
}) {
|
|
165
|
-
this.branchName = branchName;
|
|
166
|
-
this.source = source;
|
|
167
|
-
this.sourcePath = sourcePath;
|
|
168
|
-
this.userSpecifiedBranch = userSpecifiedBranch;
|
|
169
|
-
}
|
|
170
|
-
isDevEnvironmentWithUserSpecifiedBranch() {
|
|
171
|
-
return (
|
|
172
|
-
this.isDefinedInDevEnvironmentConfig() &&
|
|
173
|
-
this.userSpecifiedBranch !== undefined
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
isDefinedInDevEnvironmentConfig(): boolean {
|
|
177
|
-
return this.source === BranchSource.DEV_ENVIRONMENT;
|
|
178
|
-
}
|
|
179
|
-
isDefaultBranch(): boolean {
|
|
180
|
-
return this.source === BranchSource.DEFAULT;
|
|
181
|
-
}
|
|
182
|
-
isGitBranch(): boolean {
|
|
183
|
-
return this.source === BranchSource.GIT_REPO;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const DEFAULT_BRANCH_INFO = new CurrentBranch({
|
|
188
|
-
branchName: DEFAULT_BRANCH,
|
|
189
|
-
source: BranchSource.DEFAULT,
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// TODO (randall): Remove this and the 'index.ts' export when it is no longer needed in the CLI.
|
|
193
|
-
export function getDefaultBranchInfo(): CurrentBranch {
|
|
194
|
-
return DEFAULT_BRANCH_INFO;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Returns the current branch name, in the following order of precedence:
|
|
199
|
-
* 1. If a branch name is specified in the dev environment config, use that
|
|
200
|
-
* 2. If a branch name is specified, use that
|
|
201
|
-
* 3. If this is in a git repo, use the current branch
|
|
202
|
-
* 4. If this is not in a git repo, use the default branch
|
|
203
|
-
* @param userSpecifiedBranch - The branch name specified by the user
|
|
204
|
-
* @param pathPrefix - The path prefix to use when looking for the dev environment config
|
|
205
|
-
* @returns The current branch information
|
|
206
|
-
*/
|
|
207
|
-
export async function getCurrentBranchInfo(
|
|
208
|
-
userSpecifiedBranch?: string,
|
|
209
|
-
pathPrefix?: string,
|
|
210
|
-
): Promise<CurrentBranch> {
|
|
211
|
-
// First, if there is a dev environment config and a branch name is specified, use that
|
|
212
|
-
try {
|
|
213
|
-
const [devEnvironmentConfig, devEnvConfigPath] =
|
|
214
|
-
await getSuperblocksDevEnvironmentConfigJson(true, pathPrefix);
|
|
215
|
-
if (devEnvironmentConfig.branch) {
|
|
216
|
-
return new CurrentBranch({
|
|
217
|
-
branchName: devEnvironmentConfig.branch,
|
|
218
|
-
source: BranchSource.DEV_ENVIRONMENT,
|
|
219
|
-
sourcePath: devEnvConfigPath,
|
|
220
|
-
userSpecifiedBranch: userSpecifiedBranch,
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
} catch {
|
|
224
|
-
// Did not find or could not parse the dev environment config, so continue
|
|
225
|
-
}
|
|
226
|
-
// Second, if the user specified a branch name, use that
|
|
227
|
-
if (userSpecifiedBranch) {
|
|
228
|
-
return new CurrentBranch({
|
|
229
|
-
branchName: userSpecifiedBranch,
|
|
230
|
-
source: BranchSource.COMMAND_LINE,
|
|
231
|
-
userSpecifiedBranch: userSpecifiedBranch,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
// Third, if this is in a git repo, use the current branch
|
|
235
|
-
const currentGitBranch = await getCurrentGitBranchIfGit();
|
|
236
|
-
if (currentGitBranch) {
|
|
237
|
-
return new CurrentBranch({
|
|
238
|
-
branchName: currentGitBranch,
|
|
239
|
-
source: BranchSource.GIT_REPO,
|
|
240
|
-
userSpecifiedBranch: userSpecifiedBranch,
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
// Fourth, if this is not in a git repo, use the default branch
|
|
244
|
-
return new CurrentBranch({
|
|
245
|
-
branchName: DEFAULT_BRANCH,
|
|
246
|
-
source: BranchSource.DEFAULT,
|
|
247
|
-
userSpecifiedBranch: userSpecifiedBranch,
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
|
|
251
136
|
export async function fetchApplication({
|
|
252
137
|
cliVersion,
|
|
253
138
|
applicationId,
|
|
@@ -1,113 +1,39 @@
|
|
|
1
1
|
import { createLogger, format, transports } from "winston";
|
|
2
|
-
import type winston from "winston";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
filename: `/tmp/dev-server.log`,
|
|
11
|
-
level: "info",
|
|
12
|
-
}),
|
|
13
|
-
);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
activeTransports.push(
|
|
17
|
-
new transports.Console({
|
|
18
|
-
format: format.combine(
|
|
19
|
-
format.colorize(),
|
|
20
|
-
format.timestamp({
|
|
21
|
-
format: "HH:mm:ss.SSS",
|
|
22
|
-
}),
|
|
23
|
-
format.printf((props) => {
|
|
24
|
-
const { message, timestamp, error, level } = props;
|
|
25
|
-
const base =
|
|
26
|
-
process.env.SUPERBLOCKS_IS_CSB === "true"
|
|
27
|
-
? `${timestamp} ${message}`
|
|
28
|
-
: `${message}`;
|
|
29
|
-
if (level === "error") {
|
|
30
|
-
return `${base} ${(error as ErrorMeta["error"]).message} ${(error as ErrorMeta["error"]).stack}`;
|
|
31
|
-
}
|
|
32
|
-
return base;
|
|
33
|
-
}),
|
|
34
|
-
),
|
|
35
|
-
}),
|
|
36
|
-
);
|
|
3
|
+
export type DevLogger = {
|
|
4
|
+
debug: (message: string, ...meta: any[]) => void;
|
|
5
|
+
info: (message: string, ...meta: any[]) => void;
|
|
6
|
+
warn: (message: string, ...meta: any[]) => void;
|
|
7
|
+
error: (message: string, ...meta: any[]) => void;
|
|
8
|
+
};
|
|
37
9
|
|
|
38
10
|
const winstonLogger = createLogger({
|
|
39
|
-
level: "
|
|
11
|
+
level: "info",
|
|
40
12
|
exitOnError: false,
|
|
41
13
|
format: format.json(),
|
|
42
|
-
transports:
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export interface DevLogger {
|
|
54
|
-
log: (...messages: string[]) => void;
|
|
55
|
-
debug: (...messages: string[]) => void;
|
|
56
|
-
info: (...messages: string[]) => void;
|
|
57
|
-
warn: (...messages: string[]) => void;
|
|
58
|
-
error: (message: string, meta?: ErrorMeta) => void;
|
|
59
|
-
}
|
|
60
|
-
const logger: DevLogger = Object.freeze({
|
|
61
|
-
debug: (...messages: string[]) =>
|
|
62
|
-
winstonLogger.debug(
|
|
63
|
-
messages.length > 0 ? messages.join(" ") : (messages[0] as string),
|
|
64
|
-
),
|
|
65
|
-
log: (...messages: string[]) =>
|
|
66
|
-
winstonLogger.info(
|
|
67
|
-
messages.length > 0 ? messages.join(" ") : (messages[0] as string),
|
|
68
|
-
),
|
|
69
|
-
info: (...messages: string[]) =>
|
|
70
|
-
winstonLogger.info(
|
|
71
|
-
messages.length > 0 ? messages.join(" ") : (messages[0] as string),
|
|
72
|
-
),
|
|
73
|
-
warn: (...messages: string[]) =>
|
|
74
|
-
winstonLogger.warn(
|
|
75
|
-
messages.length > 0 ? messages.join(" ") : (messages[0] as string),
|
|
76
|
-
),
|
|
77
|
-
error: (message: string, meta?: ErrorMeta) =>
|
|
78
|
-
winstonLogger.error(message, meta),
|
|
14
|
+
transports: [
|
|
15
|
+
new transports.File({ filename: `/tmp/dev-server.log`, level: "info" }),
|
|
16
|
+
new transports.Console({
|
|
17
|
+
format: format.combine(
|
|
18
|
+
format.printf(({ message }) => `${message}`),
|
|
19
|
+
format.colorize({ message: true }),
|
|
20
|
+
),
|
|
21
|
+
level: "debug",
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
79
24
|
});
|
|
80
25
|
|
|
81
26
|
export function getLogger(
|
|
82
|
-
loggerOverride?: (
|
|
27
|
+
loggerOverride?: (message: string) => void,
|
|
83
28
|
): DevLogger {
|
|
84
29
|
if (!loggerOverride) {
|
|
85
|
-
return
|
|
30
|
+
return winstonLogger;
|
|
86
31
|
}
|
|
87
32
|
|
|
88
33
|
return {
|
|
89
34
|
debug: loggerOverride,
|
|
90
35
|
info: loggerOverride,
|
|
91
36
|
warn: loggerOverride,
|
|
92
|
-
|
|
93
|
-
error: loggerOverride as any,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function getErrorMeta(error: unknown): ErrorMeta {
|
|
98
|
-
if (error instanceof Error) {
|
|
99
|
-
return {
|
|
100
|
-
error: {
|
|
101
|
-
kind: error.name,
|
|
102
|
-
message: error.message,
|
|
103
|
-
stack: error.stack,
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
return {
|
|
108
|
-
error: {
|
|
109
|
-
kind: "Unknown Error",
|
|
110
|
-
message: JSON.stringify(error),
|
|
111
|
-
},
|
|
37
|
+
error: loggerOverride,
|
|
112
38
|
};
|
|
113
39
|
}
|
|
@@ -18,8 +18,7 @@ import {
|
|
|
18
18
|
customComponentsPlugin,
|
|
19
19
|
isCustomComponentsEnabled,
|
|
20
20
|
} from "./custom-build.mjs";
|
|
21
|
-
import {
|
|
22
|
-
import { buildManifestStubPlugin } from "./vite-plugin-build-manifest-stub.mjs";
|
|
21
|
+
import { getLogger } from "./dev-logger.mjs";
|
|
23
22
|
import { ddRumPlugin } from "./vite-plugin-dd-rum.mjs";
|
|
24
23
|
import { superblocksCdnPlugin } from "./vite-plugin-sb-cdn.mjs";
|
|
25
24
|
import type { AiService } from "@superblocksteam/vite-plugin-file-sync/ai-service";
|
|
@@ -188,6 +187,13 @@ export async function createDevServer({
|
|
|
188
187
|
}, viteReject);
|
|
189
188
|
});
|
|
190
189
|
|
|
190
|
+
// TODO(code-mode): remove this soon
|
|
191
|
+
app.get("/_sb_disconnect", async (_req, res) => {
|
|
192
|
+
console.log("GET /_sb_disconnect");
|
|
193
|
+
// TODO(code-mode): should this include any validation checks, such as getting a token?
|
|
194
|
+
await gracefulShutdown({ logger, serverInitiated: false });
|
|
195
|
+
res.send("ok");
|
|
196
|
+
});
|
|
191
197
|
app.post("/_sb_disconnect", async (req, res) => {
|
|
192
198
|
const { initiatedByEmail, switchingTo } = req.body;
|
|
193
199
|
// TODO(code-mode): should this include any validation checks, such as getting a token?
|
|
@@ -200,7 +206,7 @@ export async function createDevServer({
|
|
|
200
206
|
});
|
|
201
207
|
res.send("ok");
|
|
202
208
|
} catch (e) {
|
|
203
|
-
|
|
209
|
+
console.error("Error disconnecting from dev server", e);
|
|
204
210
|
res.status(500).send("Error disconnecting from dev server");
|
|
205
211
|
}
|
|
206
212
|
});
|
|
@@ -254,7 +260,7 @@ async function startVite({
|
|
|
254
260
|
}) {
|
|
255
261
|
const viteLogger = createLogger();
|
|
256
262
|
const logger = getLogger(loggerOverride);
|
|
257
|
-
viteLogger.info =
|
|
263
|
+
viteLogger.info = logger.info;
|
|
258
264
|
viteLogger.warn = (msg: string) => {
|
|
259
265
|
logger.warn(yellow(msg));
|
|
260
266
|
};
|
|
@@ -270,8 +276,6 @@ async function startVite({
|
|
|
270
276
|
const isCustomBuildEnabled = await isCustomComponentsEnabled();
|
|
271
277
|
const customFolder = path.join(root, "custom");
|
|
272
278
|
|
|
273
|
-
const draftsFolder = path.join(root, ".superblocks");
|
|
274
|
-
|
|
275
279
|
const cdnUrl = process.env.SUPERBLOCKS_CDN_URL ?? "http://localhost:4040/cdn";
|
|
276
280
|
|
|
277
281
|
const env = loadEnv(mode, root, "");
|
|
@@ -309,7 +313,10 @@ async function startVite({
|
|
|
309
313
|
server: {
|
|
310
314
|
middlewareMode: true,
|
|
311
315
|
watch: {
|
|
312
|
-
ignored: [
|
|
316
|
+
ignored: [
|
|
317
|
+
`${customFolder}/**/*`,
|
|
318
|
+
`${root}/.superblocks/{generations,drafts}/**/*`,
|
|
319
|
+
],
|
|
313
320
|
},
|
|
314
321
|
hmr: hmrOptions,
|
|
315
322
|
cors: {
|
|
@@ -338,13 +345,11 @@ async function startVite({
|
|
|
338
345
|
aiService,
|
|
339
346
|
httpServer,
|
|
340
347
|
tracer,
|
|
348
|
+
logger,
|
|
341
349
|
},
|
|
342
350
|
{ isCustomBuildEnabled },
|
|
343
351
|
) as Plugin,
|
|
344
352
|
|
|
345
|
-
// Add a virtual "stub" module for the build manifest
|
|
346
|
-
buildManifestStubPlugin(),
|
|
347
|
-
|
|
348
353
|
// for now, only use the CDN locally
|
|
349
354
|
superblocksCdnPlugin({
|
|
350
355
|
imports: {
|
|
@@ -6,13 +6,8 @@ import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
|
|
|
6
6
|
import { Resource } from "@opentelemetry/resources";
|
|
7
7
|
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
8
8
|
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
9
|
-
import {
|
|
10
|
-
OBS_TAG_APPLICATION_ID,
|
|
11
|
-
OBS_TAG_BRANCH,
|
|
12
|
-
} from "@superblocksteam/shared";
|
|
13
9
|
import { getLocalTokenWithUrl } from "@superblocksteam/util";
|
|
14
10
|
import packageJson from "../../package.json" with { type: "json" };
|
|
15
|
-
import type { ApplicationConfig } from "../types/index.js";
|
|
16
11
|
import type { Span } from "@opentelemetry/api";
|
|
17
12
|
|
|
18
13
|
// NOTE: @joeyagreco - this is how the "env" facet is determined in datadog: https://docs.datadoghq.com/opentelemetry/setup/collector_exporter/#3---configure-your-application
|
|
@@ -20,7 +15,6 @@ const ATTR_DEPLOYMENT_ENVIRONMENT = "deployment.environment";
|
|
|
20
15
|
// NOTE: @joeyagreco - this can be used to determine if we are using mock-csb, staging-csb, prod-csb, etc
|
|
21
16
|
const ATTR_SUPERBLOCKS_BASE_URL = "superblocks.base_url";
|
|
22
17
|
const ATTR_SUPERBLOCKS_CLI_TOKEN = "superblocks.cli_token";
|
|
23
|
-
const ATTR_SUPERBLOCKS_IS_CSB = "superblocks.is_csb";
|
|
24
18
|
let superblocksTracesUrl = undefined;
|
|
25
19
|
let superblocksHostname = "unknown";
|
|
26
20
|
let token = "unknown";
|
|
@@ -36,50 +30,45 @@ try {
|
|
|
36
30
|
console.error("[tracing init] could not determine superblocks base url", e);
|
|
37
31
|
}
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
[ATTR_SUPERBLOCKS_CLI_TOKEN]: token,
|
|
48
|
-
[OBS_TAG_APPLICATION_ID]: applicationConfig?.id,
|
|
49
|
-
[OBS_TAG_BRANCH]: applicationConfig?.branchName,
|
|
50
|
-
[ATTR_SUPERBLOCKS_IS_CSB]: process.env.SUPERBLOCKS_IS_CSB,
|
|
51
|
-
}),
|
|
52
|
-
),
|
|
53
|
-
traceExporter: new OTLPTraceExporter({
|
|
54
|
-
url: superblocksTracesUrl, // OTLPTraceExporter defaults to sending traffic to http://localhost:4318/v1/traces
|
|
33
|
+
// Initialize the OpenTelemetry SDK
|
|
34
|
+
const sdk = new NodeSDK({
|
|
35
|
+
resource: Resource.default().merge(
|
|
36
|
+
new Resource({
|
|
37
|
+
[ATTR_SERVICE_NAME]: "sdk-dev-server",
|
|
38
|
+
[ATTR_DEPLOYMENT_ENVIRONMENT]: process.env.SUPERBLOCKS_CLI_ENV,
|
|
39
|
+
[ATTR_SUPERBLOCKS_BASE_URL]: superblocksHostname,
|
|
40
|
+
[ATTR_SUPERBLOCKS_CLI_TOKEN]: token,
|
|
55
41
|
}),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
42
|
+
),
|
|
43
|
+
traceExporter: new OTLPTraceExporter({
|
|
44
|
+
url: superblocksTracesUrl, // OTLPTraceExporter defaults to sending traffic to http://localhost:4318/v1/traces
|
|
45
|
+
}),
|
|
46
|
+
contextManager: new AsyncLocalStorageContextManager(),
|
|
47
|
+
instrumentations: [
|
|
48
|
+
// Configure HTTP instrumentation with custom attributes
|
|
49
|
+
new HttpInstrumentation({
|
|
50
|
+
requestHook: (span: Span, request: any) => {
|
|
51
|
+
let resource = "GET";
|
|
52
|
+
if (request) {
|
|
53
|
+
resource = `${request.method} ${request.url || request.path}`;
|
|
54
|
+
}
|
|
55
|
+
span.setAttributes({
|
|
56
|
+
"resource.name": resource,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
// Configure Express instrumentation
|
|
61
|
+
new ExpressInstrumentation({
|
|
62
|
+
requestHook: (span: Span, request: any) => {
|
|
63
|
+
span.setAttributes({
|
|
64
|
+
"resource.name": `${request.method} ${request.url}`,
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
],
|
|
69
|
+
});
|
|
80
70
|
|
|
81
|
-
|
|
82
|
-
};
|
|
71
|
+
sdk.start();
|
|
83
72
|
|
|
84
73
|
// Get a tracer instance
|
|
85
74
|
const tracer = trace.getTracer("sdk-dev-server", packageJson.version);
|
|
@@ -224,8 +224,8 @@ async function analyzeModuleGraph(
|
|
|
224
224
|
{ content: string; binary: ArrayBuffer }
|
|
225
225
|
> = new Map(),
|
|
226
226
|
): Promise<AnalysisResult> {
|
|
227
|
-
// Avoid circular dependencies
|
|
228
|
-
if (visited.has(url)
|
|
227
|
+
// Avoid circular dependencies
|
|
228
|
+
if (visited.has(url)) {
|
|
229
229
|
return {
|
|
230
230
|
dependencies: new Set(),
|
|
231
231
|
content: "",
|
|
@@ -474,13 +474,6 @@ const wellKnownPackages = new Map<string, string>([
|
|
|
474
474
|
["react-dom", "https://esm.sh/react-dom@18.2.0"],
|
|
475
475
|
["react/jsx-runtime", "https://esm.sh/react@18.2.0/jsx-runtime"],
|
|
476
476
|
["react/jsx-dev-runtime", "https://esm.sh/react@18.2.0/jsx-dev-runtime"],
|
|
477
|
-
["./user-facing/build-manifest.js", "/assets/build-manifest.js"],
|
|
478
|
-
["/assets/user-facing/build-manifest.js", "/assets/build-manifest.js"],
|
|
479
|
-
]);
|
|
480
|
-
|
|
481
|
-
const packagesToExcludeFromCdnRedirect = new Set<string>([
|
|
482
|
-
"./user-facing/build-manifest.js",
|
|
483
|
-
"/assets/user-facing/build-manifest.js",
|
|
484
477
|
]);
|
|
485
478
|
|
|
486
479
|
const react18CdnUrl = "https://esm.sh/react@18.2.0";
|
|
@@ -780,12 +773,8 @@ export async function superblocksCdnPlugin(
|
|
|
780
773
|
// Externalize modules specified in the import map
|
|
781
774
|
// The cdn: prefix ensures they're properly resolved to the CDN URL
|
|
782
775
|
if (imports.includes(id)) {
|
|
783
|
-
const shouldRedirectToCdn = !packagesToExcludeFromCdnRedirect.has(id);
|
|
784
776
|
debug(`Externalizing module for CDN resolution: ${id}`);
|
|
785
|
-
return {
|
|
786
|
-
id: `${shouldRedirectToCdn ? "cdn:" : ""}${id}`,
|
|
787
|
-
external: true,
|
|
788
|
-
};
|
|
777
|
+
return { id: `cdn:${id}`, external: true };
|
|
789
778
|
}
|
|
790
779
|
|
|
791
780
|
return null;
|
package/src/index.ts
CHANGED
|
@@ -11,8 +11,6 @@ export {
|
|
|
11
11
|
fetchApplicationWithComponents,
|
|
12
12
|
fetchApplications,
|
|
13
13
|
fetchCurrentUser,
|
|
14
|
-
getDefaultBranchInfo,
|
|
15
|
-
getCurrentBranchInfo,
|
|
16
14
|
pushApi,
|
|
17
15
|
pushApplication,
|
|
18
16
|
registerComponents,
|
|
@@ -22,10 +20,8 @@ export {
|
|
|
22
20
|
type ApplicationWrapper,
|
|
23
21
|
type Branch,
|
|
24
22
|
type Branches,
|
|
25
|
-
type BranchSource,
|
|
26
23
|
type CodeModeApplicationWrapper,
|
|
27
24
|
type CommitDto,
|
|
28
|
-
type CurrentBranch,
|
|
29
25
|
type GetCommitsResponseBody,
|
|
30
26
|
type MultiPageApplicationWrapper,
|
|
31
27
|
type MultiPageApplicationWrapperWithComponents,
|
|
@@ -29,7 +29,7 @@ const routesFileBaseName = "routes.json";
|
|
|
29
29
|
export async function injectSuperblocksIdsPlugin(root: string) {
|
|
30
30
|
const viteLogger = createLogger();
|
|
31
31
|
const logger = getLogger();
|
|
32
|
-
viteLogger.info =
|
|
32
|
+
viteLogger.info = logger.info;
|
|
33
33
|
viteLogger.warn = (msg: string) => {
|
|
34
34
|
logger.warn(yellow(msg));
|
|
35
35
|
};
|