bulletin-deploy 0.5.1 → 0.5.3-rc.1

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { deploy } from "../src/deploy.js";
4
- import { bootstrapPool } from "../src/pool.js";
3
+ import { deploy } from "../dist/deploy.js";
4
+ import { bootstrapPool } from "../dist/pool.js";
5
5
  import * as fs from "fs";
6
6
 
7
7
  const args = process.argv.slice(2);
package/cdm.json ADDED
@@ -0,0 +1,118 @@
1
+ {
2
+ "targets": {
3
+ "acc2c3b5e912b762": {
4
+ "asset-hub": "wss://asset-hub-paseo-rpc.n.dwellir.com",
5
+ "bulletin": "https://paseo-ipfs.polkadot.io/ipfs"
6
+ }
7
+ },
8
+ "dependencies": {
9
+ "acc2c3b5e912b762": {
10
+ "@example/playground-registry": "latest"
11
+ }
12
+ },
13
+ "contracts": {
14
+ "acc2c3b5e912b762": {
15
+ "@example/playground-registry": {
16
+ "version": 2,
17
+ "address": "0x7D97a3E87c0C2fe921E471D076b95975886CEAA8",
18
+ "abi": [
19
+ {
20
+ "type": "constructor",
21
+ "inputs": [],
22
+ "stateMutability": "nonpayable"
23
+ },
24
+ {
25
+ "type": "function",
26
+ "name": "publish",
27
+ "inputs": [
28
+ {
29
+ "name": "domain",
30
+ "type": "string"
31
+ },
32
+ {
33
+ "name": "metadata_uri",
34
+ "type": "string"
35
+ }
36
+ ],
37
+ "outputs": [],
38
+ "stateMutability": "nonpayable"
39
+ },
40
+ {
41
+ "type": "function",
42
+ "name": "getMetadataUri",
43
+ "inputs": [
44
+ {
45
+ "name": "domain",
46
+ "type": "string"
47
+ }
48
+ ],
49
+ "outputs": [
50
+ {
51
+ "name": "",
52
+ "type": "tuple",
53
+ "components": [
54
+ {
55
+ "name": "isSome",
56
+ "type": "bool"
57
+ },
58
+ {
59
+ "name": "value",
60
+ "type": "string"
61
+ }
62
+ ]
63
+ }
64
+ ],
65
+ "stateMutability": "view"
66
+ },
67
+ {
68
+ "type": "function",
69
+ "name": "getDomainAt",
70
+ "inputs": [
71
+ {
72
+ "name": "index",
73
+ "type": "uint32"
74
+ }
75
+ ],
76
+ "outputs": [
77
+ {
78
+ "name": "",
79
+ "type": "string"
80
+ }
81
+ ],
82
+ "stateMutability": "view"
83
+ },
84
+ {
85
+ "type": "function",
86
+ "name": "getOwner",
87
+ "inputs": [
88
+ {
89
+ "name": "domain",
90
+ "type": "string"
91
+ }
92
+ ],
93
+ "outputs": [
94
+ {
95
+ "name": "",
96
+ "type": "address"
97
+ }
98
+ ],
99
+ "stateMutability": "view"
100
+ },
101
+ {
102
+ "type": "function",
103
+ "name": "getAppCount",
104
+ "inputs": [],
105
+ "outputs": [
106
+ {
107
+ "name": "",
108
+ "type": "uint32"
109
+ }
110
+ ],
111
+ "stateMutability": "view"
112
+ }
113
+ ],
114
+ "metadataCid": "bafk2bzacecrjrmrgumcww7oc23rllfscbxpd2lxc6p2svb26c6e5tjvmr565s"
115
+ }
116
+ }
117
+ }
118
+ }
@@ -0,0 +1,126 @@
1
+ // src/telemetry.ts
2
+ import { execSync } from "child_process";
3
+ import * as fs from "fs";
4
+ import * as path from "path";
5
+ var DEFAULT_DSN = "https://e021c025d79c4c3ade2862a11f13c40b@o4509440811401216.ingest.de.sentry.io/4511093597405264";
6
+ var DISABLED = process.env.BULLETIN_DEPLOY_TELEMETRY === "0";
7
+ var Sentry = null;
8
+ if (!DISABLED) {
9
+ try {
10
+ Sentry = await import("@sentry/node");
11
+ } catch {
12
+ }
13
+ }
14
+ function initTelemetry() {
15
+ if (!Sentry) return;
16
+ Sentry.init({
17
+ dsn: process.env.SENTRY_DSN || DEFAULT_DSN,
18
+ tracesSampleRate: 1,
19
+ environment: process.env.CI ? "ci" : "local"
20
+ });
21
+ }
22
+ function extractRepoSlug(url) {
23
+ return url.replace(/.*github\.com[:/]/, "").replace(/\.git$/, "");
24
+ }
25
+ function tryGitRemote() {
26
+ try {
27
+ return extractRepoSlug(execSync("git remote get-url origin", { encoding: "utf-8" }).trim());
28
+ } catch {
29
+ return void 0;
30
+ }
31
+ }
32
+ function tryPackageJsonRepo() {
33
+ try {
34
+ const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), "package.json"), "utf-8"));
35
+ const repo = typeof pkg.repository === "string" ? pkg.repository : pkg.repository?.url;
36
+ if (repo) return extractRepoSlug(repo);
37
+ } catch {
38
+ }
39
+ return void 0;
40
+ }
41
+ function resolveRepo(domain) {
42
+ return process.env.GITHUB_REPOSITORY || tryGitRemote() || tryPackageJsonRepo() || domain || "unknown";
43
+ }
44
+ function tryGitBranch() {
45
+ try {
46
+ return execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf-8" }).trim();
47
+ } catch {
48
+ return "unknown";
49
+ }
50
+ }
51
+ function getDeployAttributes(domain) {
52
+ return {
53
+ "deploy.repo": resolveRepo(domain),
54
+ "deploy.branch": process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || tryGitBranch(),
55
+ "deploy.source": process.env.CI ? "ci" : "local",
56
+ "deploy.pr": process.env.GITHUB_PR_NUMBER || void 0
57
+ };
58
+ }
59
+ async function withSpan(op, description, attributes, fn) {
60
+ if (!Sentry) return fn();
61
+ return Sentry.startSpan({ op, name: description, attributes }, async (span) => {
62
+ try {
63
+ return await fn();
64
+ } catch (error) {
65
+ span.setAttribute("error.message", error.message);
66
+ Sentry.setTag("deploy.phase", op);
67
+ Sentry.captureException(error);
68
+ error._sentryCaptured = true;
69
+ throw error;
70
+ }
71
+ });
72
+ }
73
+ async function withDeploySpan(domain, fn) {
74
+ if (!Sentry) return fn();
75
+ const attrs = { ...getDeployAttributes(domain), "deploy.domain": domain };
76
+ try {
77
+ return await Sentry.startSpan({ op: "deploy", name: `deploy ${domain}`, attributes: attrs }, async (span) => {
78
+ Sentry.setTags({
79
+ "deploy.repo": attrs["deploy.repo"],
80
+ "deploy.branch": attrs["deploy.branch"],
81
+ "deploy.domain": domain,
82
+ "deploy.source": attrs["deploy.source"]
83
+ });
84
+ try {
85
+ return await fn();
86
+ } catch (error) {
87
+ span.setAttribute("deploy.status", "error");
88
+ span.setAttribute("deploy.error", error.message);
89
+ if (!error._sentryCaptured) {
90
+ Sentry.setTag("deploy.phase", "deploy");
91
+ Sentry.captureException(error);
92
+ }
93
+ throw error;
94
+ }
95
+ });
96
+ } finally {
97
+ await Sentry.flush(5e3);
98
+ }
99
+ }
100
+ function setDeployAttribute(key, value) {
101
+ if (!Sentry) return;
102
+ const span = Sentry.getActiveSpan();
103
+ if (span) span.setAttribute(key, value);
104
+ }
105
+ function captureWarning(message, context) {
106
+ if (!Sentry) return;
107
+ try {
108
+ Sentry.addBreadcrumb({ level: "warning", message, data: context });
109
+ Sentry.captureMessage(message, { level: "warning", extra: context });
110
+ } catch {
111
+ }
112
+ }
113
+ async function flush() {
114
+ if (!Sentry) return;
115
+ await Sentry.flush(5e3);
116
+ }
117
+
118
+ export {
119
+ initTelemetry,
120
+ resolveRepo,
121
+ withSpan,
122
+ withDeploySpan,
123
+ setDeployAttribute,
124
+ captureWarning,
125
+ flush
126
+ };