Skip to content

Commit d1a1b34

Browse files
author
Beatriz Rizental
authored
Merge pull request #85 from brizental/1693516-type-declarations
Bug 1693516 - Publish type declarations along with @mozilla/glean package
2 parents e18af83 + 93c2f1b commit d1a1b34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+11215
-274
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
6161
nvm install node
6262
npm --prefix ./glean install
63-
npm --prefix ./glean run build
63+
npm --prefix ./glean run build:qt
6464
- run:
6565
name: Verify no Javascript errors found in Qt
6666
command: bin/qt-js-check.sh

bin/prepare-release.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ ${CHANGELOG}
103103
EOL
104104
fi
105105

106+
## Constants ###
107+
108+
FILE=glean/src/core/constants.ts
109+
110+
run $SED -i.bak -E \
111+
-e "s/export const GLEAN_VERSION = \"[0-9a-z.-]+\";/export const GLEAN_VERSION = \"${NEW_VERSION}\";/" \
112+
"${WORKSPACE_ROOT}/${FILE}"
113+
run rm "${WORKSPACE_ROOT}/${FILE}.bak"
114+
106115
echo "Everything prepared for v${NEW_VERSION}"
107116
echo
108117
echo "Changed files:"

glean/package.json

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,34 @@
44
"description": "An implementation of the Glean SDK, a modern cross-platform telemetry client, for Javascript environments.",
55
"exports": {
66
"./package.json": "./package.json",
7-
"./qt": "./dist/qt.js",
8-
"./webext": "./dist/webext.js"
7+
"./webext": "./dist/webext/index/webext.js",
8+
"./webext/private/metrics/*": "./dist/webext/core/metrics/types/*.js",
9+
"./webext/private/ping": "./dist/webext/core/pings/index.js"
10+
},
11+
"typesVersions": {
12+
"*": {
13+
"webext/*": [
14+
"./dist/webext/types/*"
15+
]
16+
}
917
},
1018
"files": [
1119
"README.md",
1220
"package.json",
13-
"dist/**/*.js"
21+
"dist/**/*"
1422
],
1523
"scripts": {
1624
"test": "npm run test:core && npm run test:platform",
17-
"test:core": "ts-mocha \"tests/core/**/*.spec.ts\" --paths -p ./tsconfig.json --recursive",
18-
"test:platform": "npm run build:test-webext && ts-mocha \"tests/platform/**/*.spec.ts\" --paths -p ./tsconfig.json --recursive --timeout 0",
25+
"test:core": "ts-mocha \"tests/core/**/*.spec.ts\" --recursive",
26+
"test:platform": "npm run build:test-webext && ts-mocha \"tests/platform/**/*.spec.ts\" --recursive --timeout 0",
1927
"build:test-webext": "cd tests/platform/utils/webext/sample/ && npm install && npm run build:xpi",
2028
"lint": "eslint . --ext .ts,.js,.json --max-warnings=0",
2129
"fix": "eslint . --ext .ts,.js,.json --fix",
22-
"build": "webpack --config webpack.config.js --mode production",
23-
"dev": "webpack --watch --config webpack.config.js --mode development --devtool inline-source-map",
24-
"prepublishOnly": "cp ../README.md ./README.md && npm run build",
30+
"build:webext:lib": "tsc -p ./tsconfig/webext/index.json",
31+
"build:webext:types": "tsc -p ./tsconfig/webext/types.json",
32+
"build:webext": "npm run build:webext:lib && npm run build:webext:types",
33+
"build:qt": "webpack --config webpack.config.qt.js --mode production",
34+
"prepublishOnly": "cp ../README.md ./README.md && npm run build:webext",
2535
"postpublish": "rm ./README.md"
2636
},
2737
"repository": {

glean/src/core/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import { DEFAULT_TELEMETRY_ENDPOINT } from "core/constants";
6-
import { validateURL } from "core/utils";
5+
import { DEFAULT_TELEMETRY_ENDPOINT } from "./constants";
6+
import { validateURL } from "./utils";
77

88
/**
99
* Lists Glean's debug options.

glean/src/core/constants.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import { version } from "../../package.json";
6-
75
export const GLEAN_SCHEMA_VERSION = 1;
86

97
// The version for the current build of Glean.js
108
//
119
// PACKAGE_VERSION is defined as a global by webpack,
1210
// we need a default here for testing when the app is not build with webpack.
13-
export const GLEAN_VERSION = version;
11+
export const GLEAN_VERSION = "0.1.1";
1412

1513
// The name of a "ping" that will include Glean ping_info metrics,
1614
// such as ping sequence numbers.

glean/src/core/dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import { generateUUIDv4 } from "core/utils";
5+
import { generateUUIDv4 } from "./utils";
66

77
// The possible states a dispatcher instance can be in.
88
export const enum DispatcherState {

glean/src/core/glean.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import { CLIENT_INFO_STORAGE, KNOWN_CLIENT_ID } from "core/constants";
6-
import { Configuration, ConfigurationInterface } from "core/config";
7-
import MetricsDatabase from "core/metrics/database";
8-
import PingsDatabase from "core/pings/database";
9-
import PingUploader from "core/upload";
10-
import { isUndefined, sanitizeApplicationId } from "core/utils";
11-
import { CoreMetrics } from "core/internal_metrics";
12-
import { Lifetime } from "core/metrics";
13-
import EventsDatabase from "core/metrics/events_database";
14-
import UUIDMetricType from "core/metrics/types/uuid";
15-
import DatetimeMetricType, { DatetimeMetric } from "core/metrics/types/datetime";
16-
import Dispatcher from "core/dispatcher";
17-
import CorePings from "core/internal_pings";
18-
19-
import Platform from "platform/index";
20-
import TestPlatform from "platform/test";
5+
import { CLIENT_INFO_STORAGE, KNOWN_CLIENT_ID } from "./constants";
6+
import { Configuration, ConfigurationInterface } from "./config";
7+
import MetricsDatabase from "./metrics/database";
8+
import PingsDatabase from "./pings/database";
9+
import PingUploader from "./upload";
10+
import { isUndefined, sanitizeApplicationId } from "./utils";
11+
import { CoreMetrics } from "./internal_metrics";
12+
import { Lifetime } from "./metrics";
13+
import EventsDatabase from "./metrics/events_database";
14+
import UUIDMetricType from "./metrics/types/uuid";
15+
import DatetimeMetricType, { DatetimeMetric } from "./metrics/types/datetime";
16+
import Dispatcher from "./dispatcher";
17+
import CorePings from "./internal_pings";
18+
19+
import Platform from "../platform/index";
20+
import TestPlatform from "../platform/test";
2121

2222
class Glean {
2323
// The Glean singleton.

glean/src/core/internal_metrics.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import { KNOWN_CLIENT_ID, CLIENT_INFO_STORAGE } from "core/constants";
6-
import UUIDMetricType from "core/metrics/types/uuid";
7-
import DatetimeMetricType from "core/metrics/types/datetime";
8-
import StringMetricType from "core/metrics/types/string";
9-
import { createMetric } from "core/metrics/utils";
10-
import TimeUnit from "core/metrics/time_unit";
11-
import { Lifetime } from "core/metrics";
12-
import { generateUUIDv4 } from "core/utils";
13-
import Glean from "core/glean";
5+
import { KNOWN_CLIENT_ID, CLIENT_INFO_STORAGE } from "./constants";
6+
import UUIDMetricType from "./metrics/types/uuid";
7+
import DatetimeMetricType from "./metrics/types/datetime";
8+
import StringMetricType from "./metrics/types/string";
9+
import { createMetric } from "./metrics/utils";
10+
import TimeUnit from "./metrics/time_unit";
11+
import { Lifetime } from "./metrics";
12+
import { generateUUIDv4 } from "./utils";
13+
import Glean from "./glean";
1414

1515
/**
1616
* Glean internal metrics.

glean/src/core/internal_pings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import { DELETION_REQUEST_PING_NAME } from "core/constants";
6-
import PingType from "core/pings";
5+
import { DELETION_REQUEST_PING_NAME } from "./constants";
6+
import PingType from "./pings";
77

88
/**
99
* Glean-provided pings, all enabled by default.

glean/src/core/metrics/database.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// * License, v. 2.0. If a copy of the MPL was not distributed with this
33
// * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import Store from "core/storage";
6-
import { MetricType, Lifetime, Metric } from "core/metrics";
7-
import { createMetric, validateMetricInternalRepresentation } from "core/metrics/utils";
8-
import { isObject, isUndefined, JSONValue } from "core/utils";
9-
import Glean from "core/glean";
5+
import Store from "../storage";
6+
import { MetricType, Lifetime, Metric } from "./";
7+
import { createMetric, validateMetricInternalRepresentation } from "./utils";
8+
import { isObject, isUndefined, JSONValue } from "../utils";
9+
import Glean from "../glean";
1010

1111
export interface Metrics {
1212
[aMetricType: string]: {

0 commit comments

Comments
 (0)