@lingo.dev/_compiler 0.9.0 → 0.10.0
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.cjs +38 -41
- package/build/index.mjs +38 -41
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ var _unplugin = require('unplugin');
|
|
|
27
27
|
// package.json
|
|
28
28
|
var package_default = {
|
|
29
29
|
name: "@lingo.dev/_compiler",
|
|
30
|
-
version: "0.
|
|
30
|
+
version: "0.10.0",
|
|
31
31
|
description: "Lingo.dev Compiler",
|
|
32
32
|
private: false,
|
|
33
33
|
repository: {
|
|
@@ -113,44 +113,41 @@ var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
|
|
|
113
113
|
// src/utils/observability.ts
|
|
114
114
|
var _nodemachineid = require('node-machine-id'); var machineIdLib = _interopRequireWildcard(_nodemachineid);
|
|
115
115
|
|
|
116
|
-
// src/utils/
|
|
116
|
+
// src/utils/org-id.ts
|
|
117
117
|
var _child_process = require('child_process');
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
function hashProjectName(fullPath) {
|
|
118
|
+
var cachedGitOrgId = void 0;
|
|
119
|
+
function extractOrg(fullPath) {
|
|
121
120
|
const parts = fullPath.split("/");
|
|
122
|
-
if (parts.length
|
|
123
|
-
return
|
|
121
|
+
if (parts.length < 1) {
|
|
122
|
+
return null;
|
|
124
123
|
}
|
|
125
|
-
|
|
126
|
-
const hashedProject = _crypto.createHash.call(void 0, "sha256").update(project).digest("hex").slice(0, 8);
|
|
127
|
-
return `${org}/${hashedProject}`;
|
|
124
|
+
return parts[0];
|
|
128
125
|
}
|
|
129
|
-
function
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
126
|
+
function getOrgId() {
|
|
127
|
+
const ciOrgId = getCIOrgId();
|
|
128
|
+
if (ciOrgId) return ciOrgId;
|
|
129
|
+
const gitOrgId = getGitOrgId();
|
|
130
|
+
if (gitOrgId) return gitOrgId;
|
|
134
131
|
return null;
|
|
135
132
|
}
|
|
136
|
-
function
|
|
133
|
+
function getCIOrgId() {
|
|
137
134
|
if (process.env.GITHUB_REPOSITORY) {
|
|
138
|
-
const
|
|
139
|
-
return `github:${
|
|
135
|
+
const org = extractOrg(process.env.GITHUB_REPOSITORY);
|
|
136
|
+
if (org) return `github:${org}`;
|
|
140
137
|
}
|
|
141
138
|
if (process.env.CI_PROJECT_PATH) {
|
|
142
|
-
const
|
|
143
|
-
return `gitlab:${
|
|
139
|
+
const org = extractOrg(process.env.CI_PROJECT_PATH);
|
|
140
|
+
if (org) return `gitlab:${org}`;
|
|
144
141
|
}
|
|
145
142
|
if (process.env.BITBUCKET_REPO_FULL_NAME) {
|
|
146
|
-
const
|
|
147
|
-
return `bitbucket:${
|
|
143
|
+
const org = extractOrg(process.env.BITBUCKET_REPO_FULL_NAME);
|
|
144
|
+
if (org) return `bitbucket:${org}`;
|
|
148
145
|
}
|
|
149
146
|
return null;
|
|
150
147
|
}
|
|
151
|
-
function
|
|
152
|
-
if (
|
|
153
|
-
return
|
|
148
|
+
function getGitOrgId() {
|
|
149
|
+
if (cachedGitOrgId !== void 0) {
|
|
150
|
+
return cachedGitOrgId;
|
|
154
151
|
}
|
|
155
152
|
try {
|
|
156
153
|
const remoteUrl = _child_process.execSync.call(void 0, "git config --get remote.origin.url", {
|
|
@@ -158,13 +155,13 @@ function getGitRepositoryId() {
|
|
|
158
155
|
stdio: ["pipe", "pipe", "ignore"]
|
|
159
156
|
}).trim();
|
|
160
157
|
if (!remoteUrl) {
|
|
161
|
-
|
|
158
|
+
cachedGitOrgId = null;
|
|
162
159
|
return null;
|
|
163
160
|
}
|
|
164
|
-
|
|
165
|
-
return
|
|
161
|
+
cachedGitOrgId = parseGitUrl(remoteUrl);
|
|
162
|
+
return cachedGitOrgId;
|
|
166
163
|
} catch (e) {
|
|
167
|
-
|
|
164
|
+
cachedGitOrgId = null;
|
|
168
165
|
return null;
|
|
169
166
|
}
|
|
170
167
|
}
|
|
@@ -182,11 +179,12 @@ function parseGitUrl(url) {
|
|
|
182
179
|
const httpsMatch = cleanUrl.match(/\/([^/]+\/[^/]+)$/);
|
|
183
180
|
const repoPath = _optionalChain([sshMatch, 'optionalAccess', _2 => _2[1]]) || _optionalChain([httpsMatch, 'optionalAccess', _3 => _3[1]]);
|
|
184
181
|
if (!repoPath) return null;
|
|
185
|
-
const
|
|
182
|
+
const org = extractOrg(repoPath);
|
|
183
|
+
if (!org) return null;
|
|
186
184
|
if (platform) {
|
|
187
|
-
return `${platform}:${
|
|
185
|
+
return `${platform}:${org}`;
|
|
188
186
|
}
|
|
189
|
-
return `git:${
|
|
187
|
+
return `git:${org}`;
|
|
190
188
|
}
|
|
191
189
|
|
|
192
190
|
// src/utils/observability.ts
|
|
@@ -219,7 +217,7 @@ async function trackEvent(event, properties) {
|
|
|
219
217
|
isByokMode: _optionalChain([properties, 'optionalAccess', _4 => _4.models]) !== "lingo.dev",
|
|
220
218
|
tracking_version: TRACKING_VERSION,
|
|
221
219
|
distinct_id_source: identityInfo.distinct_id_source,
|
|
222
|
-
|
|
220
|
+
org_id: identityInfo.org_id,
|
|
223
221
|
meta: {
|
|
224
222
|
version: process.env.npm_package_version,
|
|
225
223
|
isCi: process.env.CI === "true"
|
|
@@ -234,21 +232,20 @@ async function trackEvent(event, properties) {
|
|
|
234
232
|
}
|
|
235
233
|
}
|
|
236
234
|
async function getDistinctId() {
|
|
235
|
+
const orgId = getOrgId();
|
|
237
236
|
const email = await tryGetEmail();
|
|
238
237
|
if (email) {
|
|
239
|
-
const projectId = getRepositoryId();
|
|
240
238
|
return {
|
|
241
239
|
distinct_id: email,
|
|
242
240
|
distinct_id_source: "email",
|
|
243
|
-
|
|
241
|
+
org_id: orgId
|
|
244
242
|
};
|
|
245
243
|
}
|
|
246
|
-
|
|
247
|
-
if (repoId) {
|
|
244
|
+
if (orgId) {
|
|
248
245
|
return {
|
|
249
|
-
distinct_id:
|
|
250
|
-
distinct_id_source: "
|
|
251
|
-
|
|
246
|
+
distinct_id: orgId,
|
|
247
|
+
distinct_id_source: "git_org",
|
|
248
|
+
org_id: orgId
|
|
252
249
|
};
|
|
253
250
|
}
|
|
254
251
|
const deviceId = `device-${await machineIdLib.machineId()}`;
|
|
@@ -260,7 +257,7 @@ async function getDistinctId() {
|
|
|
260
257
|
return {
|
|
261
258
|
distinct_id: deviceId,
|
|
262
259
|
distinct_id_source: "device",
|
|
263
|
-
|
|
260
|
+
org_id: null
|
|
264
261
|
};
|
|
265
262
|
}
|
|
266
263
|
async function tryGetEmail() {
|
package/build/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ import { createUnplugin } from "unplugin";
|
|
|
27
27
|
// package.json
|
|
28
28
|
var package_default = {
|
|
29
29
|
name: "@lingo.dev/_compiler",
|
|
30
|
-
version: "0.
|
|
30
|
+
version: "0.10.0",
|
|
31
31
|
description: "Lingo.dev Compiler",
|
|
32
32
|
private: false,
|
|
33
33
|
repository: {
|
|
@@ -113,44 +113,41 @@ import dedent from "dedent";
|
|
|
113
113
|
// src/utils/observability.ts
|
|
114
114
|
import * as machineIdLib from "node-machine-id";
|
|
115
115
|
|
|
116
|
-
// src/utils/
|
|
116
|
+
// src/utils/org-id.ts
|
|
117
117
|
import { execSync } from "child_process";
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
function hashProjectName(fullPath) {
|
|
118
|
+
var cachedGitOrgId = void 0;
|
|
119
|
+
function extractOrg(fullPath) {
|
|
121
120
|
const parts = fullPath.split("/");
|
|
122
|
-
if (parts.length
|
|
123
|
-
return
|
|
121
|
+
if (parts.length < 1) {
|
|
122
|
+
return null;
|
|
124
123
|
}
|
|
125
|
-
|
|
126
|
-
const hashedProject = createHash("sha256").update(project).digest("hex").slice(0, 8);
|
|
127
|
-
return `${org}/${hashedProject}`;
|
|
124
|
+
return parts[0];
|
|
128
125
|
}
|
|
129
|
-
function
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
126
|
+
function getOrgId() {
|
|
127
|
+
const ciOrgId = getCIOrgId();
|
|
128
|
+
if (ciOrgId) return ciOrgId;
|
|
129
|
+
const gitOrgId = getGitOrgId();
|
|
130
|
+
if (gitOrgId) return gitOrgId;
|
|
134
131
|
return null;
|
|
135
132
|
}
|
|
136
|
-
function
|
|
133
|
+
function getCIOrgId() {
|
|
137
134
|
if (process.env.GITHUB_REPOSITORY) {
|
|
138
|
-
const
|
|
139
|
-
return `github:${
|
|
135
|
+
const org = extractOrg(process.env.GITHUB_REPOSITORY);
|
|
136
|
+
if (org) return `github:${org}`;
|
|
140
137
|
}
|
|
141
138
|
if (process.env.CI_PROJECT_PATH) {
|
|
142
|
-
const
|
|
143
|
-
return `gitlab:${
|
|
139
|
+
const org = extractOrg(process.env.CI_PROJECT_PATH);
|
|
140
|
+
if (org) return `gitlab:${org}`;
|
|
144
141
|
}
|
|
145
142
|
if (process.env.BITBUCKET_REPO_FULL_NAME) {
|
|
146
|
-
const
|
|
147
|
-
return `bitbucket:${
|
|
143
|
+
const org = extractOrg(process.env.BITBUCKET_REPO_FULL_NAME);
|
|
144
|
+
if (org) return `bitbucket:${org}`;
|
|
148
145
|
}
|
|
149
146
|
return null;
|
|
150
147
|
}
|
|
151
|
-
function
|
|
152
|
-
if (
|
|
153
|
-
return
|
|
148
|
+
function getGitOrgId() {
|
|
149
|
+
if (cachedGitOrgId !== void 0) {
|
|
150
|
+
return cachedGitOrgId;
|
|
154
151
|
}
|
|
155
152
|
try {
|
|
156
153
|
const remoteUrl = execSync("git config --get remote.origin.url", {
|
|
@@ -158,13 +155,13 @@ function getGitRepositoryId() {
|
|
|
158
155
|
stdio: ["pipe", "pipe", "ignore"]
|
|
159
156
|
}).trim();
|
|
160
157
|
if (!remoteUrl) {
|
|
161
|
-
|
|
158
|
+
cachedGitOrgId = null;
|
|
162
159
|
return null;
|
|
163
160
|
}
|
|
164
|
-
|
|
165
|
-
return
|
|
161
|
+
cachedGitOrgId = parseGitUrl(remoteUrl);
|
|
162
|
+
return cachedGitOrgId;
|
|
166
163
|
} catch {
|
|
167
|
-
|
|
164
|
+
cachedGitOrgId = null;
|
|
168
165
|
return null;
|
|
169
166
|
}
|
|
170
167
|
}
|
|
@@ -182,11 +179,12 @@ function parseGitUrl(url) {
|
|
|
182
179
|
const httpsMatch = cleanUrl.match(/\/([^/]+\/[^/]+)$/);
|
|
183
180
|
const repoPath = sshMatch?.[1] || httpsMatch?.[1];
|
|
184
181
|
if (!repoPath) return null;
|
|
185
|
-
const
|
|
182
|
+
const org = extractOrg(repoPath);
|
|
183
|
+
if (!org) return null;
|
|
186
184
|
if (platform) {
|
|
187
|
-
return `${platform}:${
|
|
185
|
+
return `${platform}:${org}`;
|
|
188
186
|
}
|
|
189
|
-
return `git:${
|
|
187
|
+
return `git:${org}`;
|
|
190
188
|
}
|
|
191
189
|
|
|
192
190
|
// src/utils/observability.ts
|
|
@@ -219,7 +217,7 @@ async function trackEvent(event, properties) {
|
|
|
219
217
|
isByokMode: properties?.models !== "lingo.dev",
|
|
220
218
|
tracking_version: TRACKING_VERSION,
|
|
221
219
|
distinct_id_source: identityInfo.distinct_id_source,
|
|
222
|
-
|
|
220
|
+
org_id: identityInfo.org_id,
|
|
223
221
|
meta: {
|
|
224
222
|
version: process.env.npm_package_version,
|
|
225
223
|
isCi: process.env.CI === "true"
|
|
@@ -234,21 +232,20 @@ async function trackEvent(event, properties) {
|
|
|
234
232
|
}
|
|
235
233
|
}
|
|
236
234
|
async function getDistinctId() {
|
|
235
|
+
const orgId = getOrgId();
|
|
237
236
|
const email = await tryGetEmail();
|
|
238
237
|
if (email) {
|
|
239
|
-
const projectId = getRepositoryId();
|
|
240
238
|
return {
|
|
241
239
|
distinct_id: email,
|
|
242
240
|
distinct_id_source: "email",
|
|
243
|
-
|
|
241
|
+
org_id: orgId
|
|
244
242
|
};
|
|
245
243
|
}
|
|
246
|
-
|
|
247
|
-
if (repoId) {
|
|
244
|
+
if (orgId) {
|
|
248
245
|
return {
|
|
249
|
-
distinct_id:
|
|
250
|
-
distinct_id_source: "
|
|
251
|
-
|
|
246
|
+
distinct_id: orgId,
|
|
247
|
+
distinct_id_source: "git_org",
|
|
248
|
+
org_id: orgId
|
|
252
249
|
};
|
|
253
250
|
}
|
|
254
251
|
const deviceId = `device-${await machineIdLib.machineId()}`;
|
|
@@ -260,7 +257,7 @@ async function getDistinctId() {
|
|
|
260
257
|
return {
|
|
261
258
|
distinct_id: deviceId,
|
|
262
259
|
distinct_id_source: "device",
|
|
263
|
-
|
|
260
|
+
org_id: null
|
|
264
261
|
};
|
|
265
262
|
}
|
|
266
263
|
async function tryGetEmail() {
|