@forge/cli-shared 10.0.1-next.4-experimental-e080d98 → 10.1.0-next.10
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/CHANGELOG.md +29 -10
- package/out/apps/get-app-owner.d.ts.map +1 -1
- package/out/auth/personal/me-graphql-client.d.ts +1 -3
- package/out/auth/personal/me-graphql-client.d.ts.map +1 -1
- package/out/auth/personal/me-graphql-client.js +2 -4
- package/out/auth/personal/user-repository.d.ts +1 -3
- package/out/auth/personal/user-repository.d.ts.map +1 -1
- package/out/auth/personal/user-repository.js +2 -4
- package/out/config/config-file.d.ts.map +1 -1
- package/out/config/config-file.js +2 -6
- package/out/config/index.d.ts +0 -1
- package/out/config/index.d.ts.map +1 -1
- package/out/config/index.js +0 -1
- package/out/graphql/gql/graphql.d.ts +90 -13
- package/out/graphql/gql/graphql.d.ts.map +1 -1
- package/out/service/bridge-script-service.d.ts +1 -1
- package/out/service/bridge-script-service.d.ts.map +1 -1
- package/out/service/bridge-script-service.js +3 -3
- package/out/service/iframe-resizer-script-service.d.ts +1 -1
- package/out/service/iframe-resizer-script-service.d.ts.map +1 -1
- package/out/service/iframe-resizer-script-service.js +3 -3
- package/out/service/statsig-service.d.ts +13 -2
- package/out/service/statsig-service.d.ts.map +1 -1
- package/out/service/statsig-service.js +90 -2
- package/out/service/supported-products-service.d.ts +8 -16
- package/out/service/supported-products-service.d.ts.map +1 -1
- package/out/service/supported-products-service.js +24 -60
- package/out/shared/error-handling.d.ts +2 -0
- package/out/shared/error-handling.d.ts.map +1 -1
- package/out/shared/error-handling.js +6 -1
- package/out/shared/forge-cli-attribution.d.ts +4 -0
- package/out/shared/forge-cli-attribution.d.ts.map +1 -1
- package/out/shared/forge-cli-attribution.js +15 -1
- package/out/shared/load-html.d.ts +3 -0
- package/out/shared/load-html.d.ts.map +1 -0
- package/out/shared/load-html.js +4 -0
- package/out/shared/test.d.ts.map +1 -1
- package/out/shared/test.js +1 -1
- package/out/ui/command-line-ui.d.ts +2 -0
- package/out/ui/command-line-ui.d.ts.map +1 -1
- package/out/ui/command-line-ui.js +13 -2
- package/out/ui/text.d.ts +0 -5
- package/out/ui/text.d.ts.map +1 -1
- package/out/ui/text.js +0 -5
- package/package.json +3 -2
- package/out/config/workflows-integration.d.ts +0 -18
- package/out/config/workflows-integration.d.ts.map +0 -1
- package/out/config/workflows-integration.js +0 -71
|
@@ -2,6 +2,6 @@ export declare class BridgeScriptService {
|
|
|
2
2
|
private readonly env;
|
|
3
3
|
constructor(env?: string);
|
|
4
4
|
private createBridgeCoreScriptTag;
|
|
5
|
-
injectBridgeCore(content: Buffer, onError: () => void): Buffer
|
|
5
|
+
injectBridgeCore(content: Buffer, onError: () => void): Promise<Buffer>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=bridge-script-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge-script-service.d.ts","sourceRoot":"","sources":["../../src/service/bridge-script-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bridge-script-service.d.ts","sourceRoot":"","sources":["../../src/service/bridge-script-service.ts"],"names":[],"mappings":"AAKA,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,SAAwC;IAExE,OAAO,CAAC,yBAAyB;IAIpB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;CAarF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { load } from 'cheerio';
|
|
2
1
|
import { CDNEnvironments, getEnvironmentConfig } from '../graphql/gateway.js';
|
|
2
|
+
import { loadHtml } from '../shared/load-html.js';
|
|
3
3
|
const BRIDGE_CORE_CDN_PATH = 'global-bridge.js';
|
|
4
4
|
const GLOBAL_FORGE_INSTALL_ID = 'forge';
|
|
5
5
|
export class BridgeScriptService {
|
|
@@ -10,8 +10,8 @@ export class BridgeScriptService {
|
|
|
10
10
|
createBridgeCoreScriptTag() {
|
|
11
11
|
return `<script src="https://${GLOBAL_FORGE_INSTALL_ID}.cdn.${this.env}.atlassian-dev.net/${BRIDGE_CORE_CDN_PATH}"></script>`;
|
|
12
12
|
}
|
|
13
|
-
injectBridgeCore(content, onError) {
|
|
14
|
-
const $ =
|
|
13
|
+
async injectBridgeCore(content, onError) {
|
|
14
|
+
const $ = await loadHtml(content);
|
|
15
15
|
if ($('html').length === 0)
|
|
16
16
|
onError();
|
|
17
17
|
let head = $('head');
|
|
@@ -2,6 +2,6 @@ export declare class IframeResizerScriptService {
|
|
|
2
2
|
private readonly env;
|
|
3
3
|
constructor(env?: string);
|
|
4
4
|
private createIframeResizerScriptTag;
|
|
5
|
-
injectIframeResizer(content: Buffer, onError: () => void): Buffer
|
|
5
|
+
injectIframeResizer(content: Buffer, onError: () => void): Promise<Buffer>;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=iframe-resizer-script-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe-resizer-script-service.d.ts","sourceRoot":"","sources":["../../src/service/iframe-resizer-script-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"iframe-resizer-script-service.d.ts","sourceRoot":"","sources":["../../src/service/iframe-resizer-script-service.ts"],"names":[],"mappings":"AAKA,qBAAa,0BAA0B;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,SAAwC;IAExE,OAAO,CAAC,4BAA4B;IAIvB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;CAaxF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { load } from 'cheerio';
|
|
2
1
|
import { CDNEnvironments, getEnvironmentConfig } from '../graphql/gateway.js';
|
|
2
|
+
import { loadHtml } from '../shared/load-html.js';
|
|
3
3
|
const IFRAME_RESIZER_CDN_PATH = 'iframeResizer.contentWindow.min.js';
|
|
4
4
|
const GLOBAL_FORGE_INSTALL_ID = 'forge';
|
|
5
5
|
export class IframeResizerScriptService {
|
|
@@ -10,8 +10,8 @@ export class IframeResizerScriptService {
|
|
|
10
10
|
createIframeResizerScriptTag() {
|
|
11
11
|
return `<script async src="https://${GLOBAL_FORGE_INSTALL_ID}.cdn.${this.env}.atlassian-dev.net/${IFRAME_RESIZER_CDN_PATH}"></script>`;
|
|
12
12
|
}
|
|
13
|
-
injectIframeResizer(content, onError) {
|
|
14
|
-
const $ =
|
|
13
|
+
async injectIframeResizer(content, onError) {
|
|
14
|
+
const $ = await loadHtml(content);
|
|
15
15
|
if ($('html').length === 0)
|
|
16
16
|
onError();
|
|
17
17
|
let head = $('head');
|
|
@@ -10,12 +10,18 @@ export type DynamicConfig = {
|
|
|
10
10
|
'xls-forge-cli-deprecated-runtimes': string[];
|
|
11
11
|
'forge-cli-enable-custom-spinner': string[];
|
|
12
12
|
'forge-cli-hints': string[];
|
|
13
|
-
'forge-cli-enable-create-with-module-templates': boolean;
|
|
14
13
|
};
|
|
15
14
|
export type DynamicConfigKey = keyof DynamicConfig;
|
|
15
|
+
export type Experiment = {
|
|
16
|
+
'forge-cli-create-with-module-templates': {
|
|
17
|
+
isEnabled: boolean;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export type ExperimentKey = keyof Experiment;
|
|
16
21
|
export declare abstract class StatsigReader {
|
|
17
22
|
abstract checkGate<F extends FeatureGate>(flag: F, customAttributes?: Record<string, string>): Promise<boolean | null>;
|
|
18
23
|
abstract getDynamicConfig<F extends DynamicConfigKey>(flag: F, metadata?: Record<string, string>): Promise<DynamicConfig[F] | null>;
|
|
24
|
+
abstract getExperiment<E extends ExperimentKey>(experiment: E, customAttributes?: Record<string, string>): Promise<Partial<Experiment[E]> | null>;
|
|
19
25
|
testForgeCliTestGate(): Promise<boolean>;
|
|
20
26
|
getForgeCliTestDynamicConfig(): Promise<string[]>;
|
|
21
27
|
isLogsV2ApiEnabled(): Promise<boolean>;
|
|
@@ -34,16 +40,21 @@ export declare class StatsigService extends StatsigReader {
|
|
|
34
40
|
private readonly credentialStore;
|
|
35
41
|
private readonly appConfigReader;
|
|
36
42
|
private readonly getEnvironmentFn;
|
|
43
|
+
private readonly isAnalyticsEnabled;
|
|
37
44
|
constructor(logger: Logger, cliDetails: Pick<CLIDetails, 'version'> | undefined, credentialStore: CredentialGetter, appConfigReader: ConfigSectionReader<{
|
|
38
45
|
id: string;
|
|
39
|
-
}>, getEnvironmentFn?: typeof getEnvironmentConfig);
|
|
46
|
+
}>, getEnvironmentFn?: typeof getEnvironmentConfig, isAnalyticsEnabled?: () => boolean);
|
|
40
47
|
private appID;
|
|
41
48
|
private context;
|
|
42
49
|
private fetchGates;
|
|
43
50
|
private fetchDynamicConfigs;
|
|
51
|
+
private fetchExperiments;
|
|
44
52
|
private gatesClient;
|
|
45
53
|
private dynamicConfigClient;
|
|
54
|
+
private experimentsClient;
|
|
55
|
+
private logExperimentExposure;
|
|
46
56
|
checkGate<F extends FeatureGate>(gate: F, customAttributes?: Record<string, string>): Promise<boolean | null>;
|
|
47
57
|
getDynamicConfig<F extends DynamicConfigKey>(dynamicConfig: F, metadata?: Record<string, string>): Promise<DynamicConfig[F] | null>;
|
|
58
|
+
getExperiment<E extends ExperimentKey>(experiment: E, customAttributes?: Record<string, string>): Promise<Partial<Experiment[E]> | null>;
|
|
48
59
|
}
|
|
49
60
|
//# sourceMappingURL=statsig-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statsig-service.d.ts","sourceRoot":"","sources":["../../src/service/statsig-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"statsig-service.d.ts","sourceRoot":"","sources":["../../src/service/statsig-service.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EAEpB,MAAM,E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AC,EACpD,gBAAgB,GAAE,OAAO,oBAA2C,EACpE,kBAAkB,GAAE,MAAM,OAAqB;IAKlE,OAAO,CAAC,KAAK,CAOV;IAEH,OAAO,CAAC,OAAO,CAkBb;IAEF,OAAO,CAAC,UAAU,CAgChB;IAEF,OAAO,CAAC,mBAAmB,CAgCzB;IAEF,OAAO,CAAC,gBAAgB,CAgCtB;IAEF,OAAO,CAAC,WAAW,CAGhB;IAEH,OAAO,CAAC,mBAAmB,CAGxB;IAEH,OAAO,CAAC,iBAAiB,CAGtB;IAEH,OAAO,CAAC,qBAAqB,CAgC3B;IAEI,SAAS,CAAC,CAAC,SAAS,WAAW,EACnC,IAAI,EAAE,CAAC,EACP,gBAAgB,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC5C,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAYpB,gBAAgB,CAAC,CAAC,SAAS,gBAAgB,EAC/C,aAAa,EAAE,CAAC,EAChB,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACpC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAY7B,aAAa,CAAC,CAAC,SAAS,aAAa,EACzC,UAAU,EAAE,CAAC,EACb,gBAAgB,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC5C,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAY1C"}
|
|
@@ -50,7 +50,7 @@ export class StatsigReader {
|
|
|
50
50
|
if (isFedrampEnv()) {
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
|
-
return (await this.
|
|
53
|
+
return (await this.getExperiment('forge-cli-create-with-module-templates'))?.isEnabled ?? false;
|
|
54
54
|
}
|
|
55
55
|
async getCustomSpinnerConfig() {
|
|
56
56
|
return (await this.getDynamicConfig('forge-cli-enable-custom-spinner')) ?? null;
|
|
@@ -76,6 +76,14 @@ var BASE_FEATURE_FLAG_SERVICE_URL;
|
|
|
76
76
|
BASE_FEATURE_FLAG_SERVICE_URL["FEDRAMP_MODERATE_STAGING"] = "https://api.stg.atlassian.com/flags/api/v2/";
|
|
77
77
|
BASE_FEATURE_FLAG_SERVICE_URL["FEDRAMP_MODERATE_PROD"] = "https://api.atlassian.com/flags/api/v2/";
|
|
78
78
|
})(BASE_FEATURE_FLAG_SERVICE_URL || (BASE_FEATURE_FLAG_SERVICE_URL = {}));
|
|
79
|
+
var FEATURE_GATE_ENVIRONMENTS;
|
|
80
|
+
(function (FEATURE_GATE_ENVIRONMENTS) {
|
|
81
|
+
FEATURE_GATE_ENVIRONMENTS["DEV"] = "development";
|
|
82
|
+
FEATURE_GATE_ENVIRONMENTS["STG"] = "staging";
|
|
83
|
+
FEATURE_GATE_ENVIRONMENTS["PROD"] = "production";
|
|
84
|
+
FEATURE_GATE_ENVIRONMENTS["FEDRAMP_MODERATE_STAGING"] = "staging";
|
|
85
|
+
FEATURE_GATE_ENVIRONMENTS["FEDRAMP_MODERATE_PROD"] = "production";
|
|
86
|
+
})(FEATURE_GATE_ENVIRONMENTS || (FEATURE_GATE_ENVIRONMENTS = {}));
|
|
79
87
|
export function cacheStatsigResult(getter) {
|
|
80
88
|
const cacheDict = new Map();
|
|
81
89
|
return async function (...args) {
|
|
@@ -89,19 +97,28 @@ export function cacheStatsigResult(getter) {
|
|
|
89
97
|
return value;
|
|
90
98
|
};
|
|
91
99
|
}
|
|
100
|
+
function djb2Hash(value) {
|
|
101
|
+
let hash = 0;
|
|
102
|
+
for (let i = 0; i < value.length; i++) {
|
|
103
|
+
hash = ((hash << 5) - hash + value.charCodeAt(i)) | 0;
|
|
104
|
+
}
|
|
105
|
+
return String(hash >>> 0);
|
|
106
|
+
}
|
|
92
107
|
export class StatsigService extends StatsigReader {
|
|
93
108
|
logger;
|
|
94
109
|
cliDetails;
|
|
95
110
|
credentialStore;
|
|
96
111
|
appConfigReader;
|
|
97
112
|
getEnvironmentFn;
|
|
98
|
-
|
|
113
|
+
isAnalyticsEnabled;
|
|
114
|
+
constructor(logger, cliDetails, credentialStore, appConfigReader, getEnvironmentFn = getEnvironmentConfig, isAnalyticsEnabled = () => false) {
|
|
99
115
|
super();
|
|
100
116
|
this.logger = logger;
|
|
101
117
|
this.cliDetails = cliDetails;
|
|
102
118
|
this.credentialStore = credentialStore;
|
|
103
119
|
this.appConfigReader = appConfigReader;
|
|
104
120
|
this.getEnvironmentFn = getEnvironmentFn;
|
|
121
|
+
this.isAnalyticsEnabled = isAnalyticsEnabled;
|
|
105
122
|
}
|
|
106
123
|
appID = cacheStatsigResult(async () => {
|
|
107
124
|
try {
|
|
@@ -194,6 +211,38 @@ export class StatsigService extends StatsigReader {
|
|
|
194
211
|
return { 'forge-cli-test-dynamic-configs': { value: [] } };
|
|
195
212
|
}
|
|
196
213
|
};
|
|
214
|
+
fetchExperiments = async (customAttributes) => {
|
|
215
|
+
try {
|
|
216
|
+
const baseURL = this.getEnvironmentFn(BASE_FEATURE_FLAG_SERVICE_URL);
|
|
217
|
+
const apiKey = this.getEnvironmentFn(STATSIG_API_KEYS);
|
|
218
|
+
const context = await this.context();
|
|
219
|
+
const response = await fetch(`${baseURL}/frontend/experimentValues`, {
|
|
220
|
+
headers: {
|
|
221
|
+
'x-api-key': apiKey,
|
|
222
|
+
'Content-Type': 'application/json'
|
|
223
|
+
},
|
|
224
|
+
method: 'POST',
|
|
225
|
+
body: JSON.stringify({
|
|
226
|
+
identifiers: {
|
|
227
|
+
atlassianAccountId: context.accountId,
|
|
228
|
+
randomizationId: context.appId
|
|
229
|
+
},
|
|
230
|
+
customAttributes: {
|
|
231
|
+
appId: context.appId,
|
|
232
|
+
version: context.version,
|
|
233
|
+
atlassianAccountId: context.accountId,
|
|
234
|
+
...customAttributes
|
|
235
|
+
},
|
|
236
|
+
targetApp: 'forge_cli'
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
return await response.json();
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
this.logger.debug(`Failed to fetch experiments: ${error}`);
|
|
243
|
+
return {};
|
|
244
|
+
}
|
|
245
|
+
};
|
|
197
246
|
gatesClient = cacheStatsigResult(async (customAttributes) => {
|
|
198
247
|
const gates = await this.fetchGates(customAttributes);
|
|
199
248
|
return { gates };
|
|
@@ -202,6 +251,32 @@ export class StatsigService extends StatsigReader {
|
|
|
202
251
|
const dynamicConfigs = await this.fetchDynamicConfigs(metadata);
|
|
203
252
|
return { dynamicConfigs };
|
|
204
253
|
});
|
|
254
|
+
experimentsClient = cacheStatsigResult(async (customAttributes) => {
|
|
255
|
+
const response = await this.fetchExperiments(customAttributes);
|
|
256
|
+
return { experiments: response.experimentValues?.dynamic_configs ?? {}, response };
|
|
257
|
+
});
|
|
258
|
+
logExperimentExposure = async (experiment, { experimentValues, clientSdkKey, customAttributes }) => {
|
|
259
|
+
if (!clientSdkKey || !this.isAnalyticsEnabled()) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
const featureGates = (await import('@atlaskit/feature-gate-js-client')).default.default;
|
|
264
|
+
const context = await this.context();
|
|
265
|
+
await featureGates.initializeFromValues({
|
|
266
|
+
sdkKey: clientSdkKey,
|
|
267
|
+
environment: this.getEnvironmentFn(FEATURE_GATE_ENVIRONMENTS),
|
|
268
|
+
targetApp: 'forge_cli',
|
|
269
|
+
ignoreWindowUndefined: true,
|
|
270
|
+
loggingEnabled: 'always',
|
|
271
|
+
logLevel: 0
|
|
272
|
+
}, { atlassianAccountId: context.accountId }, customAttributes, experimentValues);
|
|
273
|
+
featureGates.manuallyLogExperimentExposure(experiment);
|
|
274
|
+
featureGates.shutdownStatsig();
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
this.logger.debug(`Failed to log experiment exposure: ${error}`);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
205
280
|
async checkGate(gate, customAttributes = {}) {
|
|
206
281
|
try {
|
|
207
282
|
const { gates } = await this.gatesClient(customAttributes, {});
|
|
@@ -226,4 +301,17 @@ export class StatsigService extends StatsigReader {
|
|
|
226
301
|
return null;
|
|
227
302
|
}
|
|
228
303
|
}
|
|
304
|
+
async getExperiment(experiment, customAttributes = {}) {
|
|
305
|
+
try {
|
|
306
|
+
const { experiments, response } = await this.experimentsClient(customAttributes, {});
|
|
307
|
+
await this.logExperimentExposure(experiment, response);
|
|
308
|
+
return experiments[djb2Hash(experiment)]?.value ?? null;
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
if (this.logger.traceEnabled) {
|
|
312
|
+
this.logger.warn(Text.warning.statsigFetchFailed('experiments'));
|
|
313
|
+
}
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
229
317
|
}
|
|
@@ -11,27 +11,19 @@ export type ProductDefinition = {
|
|
|
11
11
|
isEnabledByFeatureGate?: (statsigService: StatsigService) => Promise<boolean>;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
declare class SupportedProductEntry {
|
|
15
|
-
productName: SupportedProduct;
|
|
16
|
-
productType: ProductType;
|
|
17
|
-
supportedByCrossProductApps: boolean;
|
|
18
|
-
constructor(productName: SupportedProduct, productType: ProductType, supportedByCrossProductApps: boolean);
|
|
19
|
-
}
|
|
20
|
-
declare function resolveEnabledProducts(statsigService: StatsigService): Promise<SupportedProductEntry[]>;
|
|
21
14
|
export declare class SupportedProductsService {
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
15
|
+
private readonly statsigService;
|
|
16
|
+
private readonly definitions;
|
|
17
|
+
private enabledProducts;
|
|
18
|
+
private enabledProductsPromise?;
|
|
19
|
+
constructor(statsigService: StatsigService, definitions?: Readonly<ProductDefinition[]>);
|
|
20
|
+
getSupportedProducts(): Promise<SupportedProduct[]>;
|
|
21
|
+
getSupportedProductsIfResolved(): SupportedProduct[];
|
|
27
22
|
getSupportedSecondaryProductsForXPA(requiredProducts: string[]): SupportedProduct[];
|
|
28
|
-
validateSupportedProduct(productNameInput: string): SupportedProduct
|
|
23
|
+
validateSupportedProduct(productNameInput: string): Promise<SupportedProduct>;
|
|
29
24
|
isWorkspaceProduct(product: string): boolean;
|
|
30
25
|
validateSite(site: string, product: ProductDisplayName | undefined): URL;
|
|
31
26
|
}
|
|
32
27
|
export declare const isBitbucketProduct: (product: string) => boolean;
|
|
33
|
-
export declare const TEST_ONLY_EXPORTS: {
|
|
34
|
-
resolveEnabledProducts: typeof resolveEnabledProducts;
|
|
35
|
-
};
|
|
36
28
|
export {};
|
|
37
29
|
//# sourceMappingURL=supported-products-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supported-products-service.d.ts","sourceRoot":"","sources":["../../src/service/supported-products-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAuC,MAAM,oBAAoB,CAAC;AAK7F,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,gBAAgB,GAAG,OAAO,GAAG,WAAW,CAAC;AAuC5G,KAAK,WAAW,GAAG,OAAO,GAAG,WAAW,CAAC;AAEzC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,CAAC,EAAE;QACR,2BAA2B,CAAC,EAAE,OAAO,CAAC;QACtC,sBAAsB,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;KAC/E,CAAC;CACH,CAAC;
|
|
1
|
+
{"version":3,"file":"supported-products-service.d.ts","sourceRoot":"","sources":["../../src/service/supported-products-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC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@ -35,72 +35,38 @@ const SUPPORTED_PRODUCTS_DEFINITIONS = [
|
|
|
35
35
|
productType: 'workspace'
|
|
36
36
|
}
|
|
37
37
|
];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
constructor(productName, productType, supportedByCrossProductApps) {
|
|
43
|
-
this.productName = productName;
|
|
44
|
-
this.productType = productType;
|
|
45
|
-
this.supportedByCrossProductApps = supportedByCrossProductApps;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async function resolveEnabledProducts(statsigService) {
|
|
49
|
-
const productDefinitionWithIsEnabledResolved = await Promise.all(SUPPORTED_PRODUCTS_DEFINITIONS.map(async (pd) => {
|
|
50
|
-
const enabledByFeatureGateResolver = pd.special?.isEnabledByFeatureGate;
|
|
51
|
-
const isEnabled = enabledByFeatureGateResolver ? await enabledByFeatureGateResolver(statsigService) : true;
|
|
52
|
-
return { pd, isEnabled };
|
|
38
|
+
async function resolveEnabledProducts(definitions, statsigService) {
|
|
39
|
+
const resolved = await Promise.all(definitions.map(async (pd) => {
|
|
40
|
+
const isEnabledByFeatureGate = pd.special?.isEnabledByFeatureGate;
|
|
41
|
+
return { pd, isEnabled: isEnabledByFeatureGate ? await isEnabledByFeatureGate(statsigService) : true };
|
|
53
42
|
}));
|
|
54
|
-
|
|
55
|
-
.filter(({ isEnabled }) => isEnabled)
|
|
56
|
-
.map(({ pd }) => pd);
|
|
57
|
-
return definitionsForEnabledProducts.map((pd) => {
|
|
58
|
-
return new SupportedProductEntry(pd.name, pd.productType, pd.special?.supportedByCrossProductApps ?? false);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
class SupportedProductEntriesHolder {
|
|
62
|
-
value;
|
|
63
|
-
constructor(value) {
|
|
64
|
-
this.value = value;
|
|
65
|
-
}
|
|
66
|
-
async initialize(valueProvider) {
|
|
67
|
-
if (this.value) {
|
|
68
|
-
throw new Error('SupportedProductsService was already initialized - is initialization called multiple times?');
|
|
69
|
-
}
|
|
70
|
-
this.value = await valueProvider();
|
|
71
|
-
}
|
|
72
|
-
get() {
|
|
73
|
-
if (!this.value) {
|
|
74
|
-
throw new Error('SupportedProductsService is not initialized - are you calling it from some constructor?');
|
|
75
|
-
}
|
|
76
|
-
return this.value;
|
|
77
|
-
}
|
|
43
|
+
return resolved.filter(({ isEnabled }) => isEnabled).map(({ pd }) => pd.name);
|
|
78
44
|
}
|
|
79
45
|
export class SupportedProductsService {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
46
|
+
statsigService;
|
|
47
|
+
definitions;
|
|
48
|
+
enabledProducts;
|
|
49
|
+
enabledProductsPromise;
|
|
50
|
+
constructor(statsigService, definitions = SUPPORTED_PRODUCTS_DEFINITIONS) {
|
|
51
|
+
this.statsigService = statsigService;
|
|
52
|
+
this.definitions = definitions;
|
|
83
53
|
}
|
|
84
|
-
async
|
|
85
|
-
|
|
54
|
+
async getSupportedProducts() {
|
|
55
|
+
this.enabledProductsPromise ??= resolveEnabledProducts(this.definitions, this.statsigService).then((products) => (this.enabledProducts = products));
|
|
56
|
+
return this.enabledProductsPromise;
|
|
86
57
|
}
|
|
87
|
-
|
|
88
|
-
return this.
|
|
89
|
-
.get()
|
|
90
|
-
.filter((p) => filter(p))
|
|
91
|
-
.map((p) => p.productName);
|
|
92
|
-
}
|
|
93
|
-
getSupportedProducts() {
|
|
94
|
-
return this.supportedProductEntriesHolder.get().map((p) => p.productName);
|
|
58
|
+
getSupportedProductsIfResolved() {
|
|
59
|
+
return (this.enabledProducts ?? this.definitions.filter((pd) => !pd.special?.isEnabledByFeatureGate).map((pd) => pd.name));
|
|
95
60
|
}
|
|
96
61
|
getSupportedSecondaryProductsForXPA(requiredProducts) {
|
|
97
62
|
const requiredProductsNames = requiredProducts.map((p) => productDisplayName(p));
|
|
98
|
-
return this.
|
|
63
|
+
return this.definitions
|
|
64
|
+
.filter((pd) => pd.special?.supportedByCrossProductApps && !requiredProductsNames.includes(pd.name))
|
|
65
|
+
.map((pd) => pd.name);
|
|
99
66
|
}
|
|
100
|
-
validateSupportedProduct(productNameInput) {
|
|
67
|
+
async validateSupportedProduct(productNameInput) {
|
|
101
68
|
const productName = productDisplayName(productNameInput);
|
|
102
|
-
|
|
103
|
-
if (supportedProducts.includes(productName)) {
|
|
69
|
+
if ((await this.getSupportedProducts()).includes(productName)) {
|
|
104
70
|
return productName;
|
|
105
71
|
}
|
|
106
72
|
else {
|
|
@@ -108,7 +74,8 @@ export class SupportedProductsService {
|
|
|
108
74
|
}
|
|
109
75
|
}
|
|
110
76
|
isWorkspaceProduct(product) {
|
|
111
|
-
|
|
77
|
+
const name = productDisplayName(product);
|
|
78
|
+
return this.definitions.some((pd) => pd.productType === 'workspace' && pd.name === name);
|
|
112
79
|
}
|
|
113
80
|
validateSite(site, product) {
|
|
114
81
|
const trySites = [site, `https://${site}`];
|
|
@@ -130,6 +97,3 @@ export class SupportedProductsService {
|
|
|
130
97
|
export const isBitbucketProduct = (product) => {
|
|
131
98
|
return productDisplayName(product) === 'Bitbucket';
|
|
132
99
|
};
|
|
133
|
-
export const TEST_ONLY_EXPORTS = {
|
|
134
|
-
resolveEnabledProducts
|
|
135
|
-
};
|
|
@@ -25,6 +25,8 @@ export interface AutoAnalyzeErrorInput {
|
|
|
25
25
|
assistantName?: string;
|
|
26
26
|
prompt?: string;
|
|
27
27
|
}
|
|
28
|
+
export declare const markSentryInitialised: () => void;
|
|
29
|
+
export declare const isSentryInitialised: () => boolean;
|
|
28
30
|
export declare const NO_HINT: null;
|
|
29
31
|
export declare const exitOnError: (logger: Logger, error: Error, hint?: string | null, autoAnalyzeErrorInput?: AutoAnalyzeErrorInput) => Promise<never>;
|
|
30
32
|
export declare const wrapError: (error: unknown) => Error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/shared/error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAA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AAU;gBAD3B,OAAO,CAAC,EAAE,MAAM,EACC,UAAU,GAAE,OAAe;IAKvC,WAAW;CAGnB;AAUD,qBAAa,wBAAyB,SAAQ,SAAS;gBAMzC,OAAO,CAAC,EAAE,MAAM;CAG7B;AAUD,qBAAa,mBAAoB,SAAQ,SAAS;gBAMpC,OAAO,CAAC,EAAE,MAAM;CAG7B"}
|
|
@@ -83,10 +83,15 @@ function removePrefixFromErrorMessage(message) {
|
|
|
83
83
|
}
|
|
84
84
|
return message;
|
|
85
85
|
}
|
|
86
|
+
let sentryInitialised = false;
|
|
87
|
+
export const markSentryInitialised = () => {
|
|
88
|
+
sentryInitialised = true;
|
|
89
|
+
};
|
|
90
|
+
export const isSentryInitialised = () => sentryInitialised;
|
|
86
91
|
export const NO_HINT = null;
|
|
87
92
|
export const exitOnError = async (logger, error, hint, autoAnalyzeErrorInput) => {
|
|
88
93
|
let exitCode = 0;
|
|
89
|
-
const Sentry = await import('@sentry/node').catch(() => undefined);
|
|
94
|
+
const Sentry = sentryInitialised ? await import('@sentry/node').catch(() => undefined) : undefined;
|
|
90
95
|
Sentry?.withScope((scope) => {
|
|
91
96
|
scope.setTag('userError', isUserError(error));
|
|
92
97
|
scope.setFingerprint(['{{ default }}', '{{ tags.command.name }}']);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export type SessionAttributionResolver = (attribution: Record<string, unknown>) => Record<string, string>;
|
|
1
2
|
export declare class ForgeCliAttribution {
|
|
3
|
+
private static sessionResolver;
|
|
4
|
+
static setSessionResolver(resolver: SessionAttributionResolver | undefined): void;
|
|
2
5
|
static isAgent(): boolean;
|
|
3
6
|
static isCI(): boolean;
|
|
4
7
|
static isAgentV2(): Promise<boolean>;
|
|
@@ -8,6 +11,7 @@ export declare class ForgeCliAttribution {
|
|
|
8
11
|
static agentHint(): Promise<string>;
|
|
9
12
|
static isStudio(): boolean;
|
|
10
13
|
static build(): Promise<Record<string, unknown>>;
|
|
14
|
+
private static resolveSession;
|
|
11
15
|
private static getWildcardAttribution;
|
|
12
16
|
private static getValidAttributionEnvValue;
|
|
13
17
|
private static isValidAttributionValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forge-cli-attribution.d.ts","sourceRoot":"","sources":["../../src/shared/forge-cli-attribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"forge-cli-attribution.d.ts","sourceRoot":"","sources":["../../src/shared/forge-cli-attribution.ts"],"names":[],"mappings":"AA4DA,MAAM,MAAM,0BAA0B,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1G,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,eAAe,CAAyC;WAMzD,kBAAkB,CAAC,QAAQ,EAAE,0BAA0B,GAAG,SAAS,GAAG,IAAI;WAY1E,OAAO,IAAI,OAAO;WASlB,IAAI,IAAI,OAAO;WAST,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;WAKnC,MAAM,IAAI,OAAO;WASjB,MAAM,IAAI,MAAM;WAIhB,SAAS,IAAI,MAAM;WASb,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;WAwBlC,QAAQ,IAAI,OAAO;WAWb,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA8B7D,OAAO,CAAC,MAAM,CAAC,cAAc;IAQ7B,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAgDrC,OAAO,CAAC,MAAM,CAAC,2BAA2B;IAK1C,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAStC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAIjC,OAAO,CAAC,MAAM,CAAC,YAAY;IAK3B,OAAO,CAAC,MAAM,CAAC,eAAe;IAS9B,OAAO,CAAC,MAAM,CAAC,UAAU;CAG1B"}
|
|
@@ -19,11 +19,16 @@ const RESERVED_ATTRIBUTION_FIELDS = new Set([
|
|
|
19
19
|
'isStudio',
|
|
20
20
|
'service',
|
|
21
21
|
'skillName',
|
|
22
|
+
'sessionIdSource',
|
|
22
23
|
'ciHint',
|
|
23
24
|
'isTerminal',
|
|
24
25
|
'isUnrecognizedNonTTY'
|
|
25
26
|
].map((field) => field.toLowerCase()));
|
|
26
27
|
export class ForgeCliAttribution {
|
|
28
|
+
static sessionResolver;
|
|
29
|
+
static setSessionResolver(resolver) {
|
|
30
|
+
this.sessionResolver = resolver;
|
|
31
|
+
}
|
|
27
32
|
static isAgent() {
|
|
28
33
|
return !process.stdin.isTTY && !process.stdout.isTTY && !this.isCI();
|
|
29
34
|
}
|
|
@@ -72,7 +77,7 @@ export class ForgeCliAttribution {
|
|
|
72
77
|
const isAgentV2 = agentHint !== UNKNOWN;
|
|
73
78
|
const isCIV2 = ciHint !== UNKNOWN;
|
|
74
79
|
const signals = readRunnerSignals(isAgentV2, isCIV2);
|
|
75
|
-
|
|
80
|
+
const attribution = {
|
|
76
81
|
isAgent: this.isAgent(),
|
|
77
82
|
isCI: this.isCI(),
|
|
78
83
|
skillName: this.skillName(),
|
|
@@ -85,6 +90,15 @@ export class ForgeCliAttribution {
|
|
|
85
90
|
isUnrecognizedNonTTY: String(signals.isUnrecognizedNonTTY),
|
|
86
91
|
...this.getWildcardAttribution()
|
|
87
92
|
};
|
|
93
|
+
return { ...attribution, ...this.resolveSession(attribution) };
|
|
94
|
+
}
|
|
95
|
+
static resolveSession(attribution) {
|
|
96
|
+
try {
|
|
97
|
+
return this.sessionResolver?.(attribution) ?? {};
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
88
102
|
}
|
|
89
103
|
static getWildcardAttribution() {
|
|
90
104
|
const wildcardAttribution = {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-html.d.ts","sourceRoot":"","sources":["../../src/shared/load-html.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,eAAO,MAAM,QAAQ,GAAU,SAAS,MAAM,GAAG,MAAM,KAAG,OAAO,CAAC,UAAU,CAG3E,CAAC"}
|
package/out/shared/test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/shared/test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/shared/test.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,wBAAgB,UAAU,CAAC,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,GAAG,MAAM,CAU/E;AAED,KAAK,OAAO,GAAG;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC/C,CAAC;AAEF,wBAAsB,aAAa,CAAC,EAClC,QAAQ,EACR,gBAA0B,EAC1B,iBAAwB,EACxB,QAAQ,EACR,cAAsB,EACvB,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,OAAO,CAAC,OAAO,CAAC,CAiDnB"}
|
package/out/shared/test.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { writeFile } from 'fs/promises';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { ensureDir, ensureSymlink } from 'fs-extra';
|
|
4
3
|
import { tmpDir } from './directories.js';
|
|
5
4
|
export function mockLogger(traceEnabled, debugEnabled) {
|
|
6
5
|
return {
|
|
@@ -14,6 +13,7 @@ export function mockLogger(traceEnabled, debugEnabled) {
|
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
15
|
export async function createTestApp({ userCode, userCodeFilename = 'index', userCodeExtension = 'ts', packages, withI18nBundle = false }) {
|
|
16
|
+
const { ensureDir, ensureSymlink } = await import('fs-extra');
|
|
17
17
|
const appDirectory = tmpDir();
|
|
18
18
|
const { SOURCE_DIRECTORY } = await import('@forge/manifest');
|
|
19
19
|
const userCodeDir = path.join(appDirectory, SOURCE_DIRECTORY, path.dirname(userCodeFilename));
|
|
@@ -17,6 +17,8 @@ export declare class CommandLineUI implements UI {
|
|
|
17
17
|
private insideProgress;
|
|
18
18
|
private statsigService;
|
|
19
19
|
private cachedSpinnerConfig;
|
|
20
|
+
private customSpinnerRequested;
|
|
21
|
+
private showsConfiguredSpinner;
|
|
20
22
|
private static HINT_ROTATION_INTERVAL_MS;
|
|
21
23
|
private hintLine;
|
|
22
24
|
private hintTimer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-line-ui.d.ts","sourceRoot":"","sources":["../../src/ui/command-line-ui.ts"],"names":[],"mappings":"AAKA,OAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAQ/B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,EAAW,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAoBxE,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,KAAK,SAAS,CAAC,GAAG,SAAS,MAAM,IAAI,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;AAQjF,qBAAa,aAAc,YAAW,EAAE;
|
|
1
|
+
{"version":3,"file":"command-line-ui.d.ts","sourceRoot":"","sources":["../../src/ui/command-line-ui.ts"],"names":[],"mappings":"AAKA,OAAY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