@interactivethings/scripts 2.0.2 → 2.1.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.
Files changed (41) hide show
  1. package/dist/cli.js +21 -12
  2. package/dist/cloudflare/cli.js +90 -0
  3. package/dist/cloudflare/cloudflare.js +44 -0
  4. package/dist/cloudflare/deployments.js +14 -0
  5. package/dist/config.js +12 -6
  6. package/dist/figma/cli.js +7 -5
  7. package/dist/figma/cli.test.js +8 -7
  8. package/dist/init/cli.js +9 -6
  9. package/dist/shared/cli.js +13 -0
  10. package/dist/shared/deployment-service.js +2 -0
  11. package/dist/shared/wait-deployment.js +29 -0
  12. package/dist/tokens-studio/cli.js +5 -3
  13. package/dist/tokens-studio/cli.test.js +8 -4
  14. package/dist/vercel/cli.js +7 -5
  15. package/dist/vercel/cli.test.js +9 -5
  16. package/dist/vercel/deployments.js +9 -36
  17. package/dist/vercel/vercel.js +31 -0
  18. package/package.json +5 -7
  19. package/dist/__tests__/figma-cli.test.js +0 -189
  20. package/dist/__tests__/tokens-studio-cli.test.js +0 -197
  21. package/dist/__tests__/vercel-cli.test.js +0 -86
  22. package/dist/cli.d.ts +0 -2
  23. package/dist/config.d.ts +0 -78
  24. package/dist/figma/api.d.ts +0 -71
  25. package/dist/figma/cli.d.ts +0 -20
  26. package/dist/figma/optimizeImage.js +0 -53
  27. package/dist/figma/utils.d.ts +0 -10
  28. package/dist/index.d.ts +0 -8
  29. package/dist/init/cli.d.ts +0 -3
  30. package/dist/mui-tokens-studio.js +0 -177
  31. package/dist/plugins/figma/index.js +0 -653
  32. package/dist/plugins/tokens-studio/utils.js +0 -155
  33. package/dist/tokens-studio/cli.d.ts +0 -8
  34. package/dist/tokens-studio/index.d.ts +0 -14
  35. package/dist/tokens-studio/mui.js +0 -212
  36. package/dist/tokens-studio/tailwind.js +0 -211
  37. package/dist/tokens-studio/utils.d.ts +0 -49
  38. package/dist/types.d.ts +0 -1
  39. package/dist/vercel/cli.d.ts +0 -4
  40. package/dist/vercel/waitForDeploymentReady.js +0 -43
  41. package/dist/wait-for-vercel-deploy.js +0 -79
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.waitForDeploymentReady = void 0;
4
- const cli_1 = require("@interactivethings/scripts/vercel/cli");
5
- async function fetchDeploymentForCommit(commitSha, teamId, projectId) {
6
- try {
7
- const response = await fetch(`https://vercel.com/api/v6/deployments?limit=20&projectId=${projectId}&state=READY,ERROR,BUILDING,QUEUED&teamId=${teamId}`, {
8
- headers: {
9
- Authorization: `Bearer ${cli_1.accessToken}`,
10
- },
11
- }).then((x) => x.json());
12
- const deployments = response.deployments.filter((deployment) => deployment.meta.githubCommitSha === commitSha);
13
- return deployments;
14
- }
15
- catch (error) {
16
- console.error("Error:", error);
17
- return [];
18
- }
19
- }
20
- const sleep = (duration) => new Promise((resolve) => setTimeout(resolve, duration));
21
- async function waitForDeploymentReady({ team, project, commitSha, interval, timeout, }) {
22
- const start = Date.now();
23
- const end = start + timeout;
24
- while (Date.now() < end) {
25
- const deployments = await fetchDeploymentForCommit(commitSha, team, project);
26
- if (deployments.length === 0 || deployments[0].state !== "READY") {
27
- const state = deployments[0].state;
28
- if (state === "ERROR") {
29
- throw new Error("Deployment errored");
30
- }
31
- console.log(`Deployment not yet ready (state: ${deployments[0].state}), waiting ${interval}ms for deployment with commit ${commitSha}`);
32
- await sleep(Math.min(end - Date.now(), interval));
33
- }
34
- else {
35
- console.log(`Deployment for commit ${commitSha} is READY`);
36
- return deployments[0];
37
- }
38
- }
39
- if (Date.now() > end) {
40
- throw new Error("Timeout for waitForDeploymentReady");
41
- }
42
- }
43
- exports.waitForDeploymentReady = waitForDeploymentReady;
@@ -1,79 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const argparse_1 = require("argparse");
5
- const accessToken = process.env.VERCEL_TOKEN;
6
- async function fetchDeploymentForCommit(commitSha, teamId, projectId) {
7
- try {
8
- const response = await fetch(`https://vercel.com/api/v6/deployments?limit=20&projectId=${projectId}&state=READY,ERROR,BUILDING,QUEUED&teamId=${teamId}`, {
9
- headers: {
10
- Authorization: `Bearer ${accessToken}`,
11
- },
12
- }).then((x) => x.json());
13
- const deployments = response.deployments.filter((deployment) => deployment.meta.githubCommitSha === commitSha);
14
- return deployments;
15
- }
16
- catch (error) {
17
- console.error("Error:", error);
18
- return [];
19
- }
20
- }
21
- const sleep = (duration) => new Promise((resolve) => setTimeout(resolve, duration));
22
- async function waitForDeploymentReady({ team, project, commitSha, interval, timeout, }) {
23
- const start = Date.now();
24
- const end = start + timeout;
25
- while (Date.now() < end) {
26
- const deployments = await fetchDeploymentForCommit(commitSha, team, project);
27
- if (deployments.length === 0 || deployments[0].state !== "READY") {
28
- const state = deployments[0].state;
29
- if (state === "ERROR") {
30
- throw new Error("Deployment errored");
31
- }
32
- console.log(`Deployment not yet ready (state: ${deployments[0].state}), waiting ${interval}ms for deployment with commit ${commitSha}`);
33
- await sleep(Math.min(end - Date.now(), interval));
34
- }
35
- else {
36
- console.log(`Deployment for commit ${commitSha} is READY`);
37
- return deployments[0];
38
- }
39
- }
40
- if (Date.now() > end) {
41
- throw new Error("Timeout for waitForDeploymentReady");
42
- }
43
- }
44
- async function main() {
45
- const parser = new argparse_1.ArgumentParser();
46
- parser.add_argument("commit", {
47
- help: "Commit that started the deployment",
48
- });
49
- parser.add_argument("--interval", {
50
- default: 5000,
51
- type: Number,
52
- });
53
- parser.add_argument("--project", {
54
- required: true,
55
- });
56
- parser.add_argument("--team", {
57
- required: true,
58
- });
59
- parser.add_argument("--timeout", {
60
- default: 10 * 60 * 1000,
61
- type: Number,
62
- });
63
- const args = parser.parse_args();
64
- const deployment = await waitForDeploymentReady({
65
- commitSha: args.commit,
66
- interval: args.interval,
67
- timeout: args.timeout,
68
- team: args.team,
69
- project: args.project,
70
- });
71
- if (!deployment) {
72
- throw new Error("Could not retrieve deployment");
73
- }
74
- console.log(`DEPLOYMENT_URL=https://${deployment.url}`);
75
- }
76
- main().catch((e) => {
77
- console.error(e);
78
- process.exit(1);
79
- });