@magland/mochi 0.3.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.
Files changed (116) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +108 -0
  3. package/dist/ansi.js +174 -0
  4. package/dist/api/admin.js +416 -0
  5. package/dist/api/auth.js +166 -0
  6. package/dist/api/backup.js +598 -0
  7. package/dist/api/ci.js +336 -0
  8. package/dist/api/contents.js +339 -0
  9. package/dist/api/issues.js +165 -0
  10. package/dist/api/pulls.js +244 -0
  11. package/dist/api/releases.js +83 -0
  12. package/dist/api/repos.js +156 -0
  13. package/dist/api/write.js +518 -0
  14. package/dist/api.js +326 -0
  15. package/dist/assets.js +29 -0
  16. package/dist/atom.js +32 -0
  17. package/dist/atomic.js +171 -0
  18. package/dist/avatar.js +81 -0
  19. package/dist/browse.js +630 -0
  20. package/dist/build-info.json +4 -0
  21. package/dist/ci/actionref.js +86 -0
  22. package/dist/ci/api.js +829 -0
  23. package/dist/ci/artifacts.js +201 -0
  24. package/dist/ci/dispatch.js +30 -0
  25. package/dist/ci/engine.js +1321 -0
  26. package/dist/ci/expr.js +526 -0
  27. package/dist/ci/manual.js +199 -0
  28. package/dist/ci/present.js +82 -0
  29. package/dist/ci/protocol.js +6 -0
  30. package/dist/ci/runners.js +256 -0
  31. package/dist/ci/runs.js +208 -0
  32. package/dist/ci/trigger.js +28 -0
  33. package/dist/ci/views.js +441 -0
  34. package/dist/ci/wake.js +194 -0
  35. package/dist/ci/web.js +617 -0
  36. package/dist/ci/workflow.js +436 -0
  37. package/dist/cli/admin-cmd.js +324 -0
  38. package/dist/cli/api-cmd.js +128 -0
  39. package/dist/cli/backup-cmd.js +1500 -0
  40. package/dist/cli/exit.js +69 -0
  41. package/dist/cli/input.js +64 -0
  42. package/dist/cli/issue-cmd.js +243 -0
  43. package/dist/cli/output.js +93 -0
  44. package/dist/cli/parse.js +317 -0
  45. package/dist/cli/pr-cmd.js +289 -0
  46. package/dist/cli/release-cmd.js +171 -0
  47. package/dist/cli/repo-cmd.js +763 -0
  48. package/dist/cli/repo.js +101 -0
  49. package/dist/cli/run-cmd.js +438 -0
  50. package/dist/cli/target.js +54 -0
  51. package/dist/cli-api.js +84 -0
  52. package/dist/compare.js +111 -0
  53. package/dist/config.js +212 -0
  54. package/dist/credentials.js +235 -0
  55. package/dist/deploy-cli.js +859 -0
  56. package/dist/deploy-runner-cli.js +592 -0
  57. package/dist/diff.js +171 -0
  58. package/dist/discussion.js +253 -0
  59. package/dist/egress.js +559 -0
  60. package/dist/filecache.js +68 -0
  61. package/dist/find.js +162 -0
  62. package/dist/forms.js +737 -0
  63. package/dist/git.js +547 -0
  64. package/dist/githttp.js +428 -0
  65. package/dist/html.js +87 -0
  66. package/dist/icons.js +101 -0
  67. package/dist/import-cli.js +316 -0
  68. package/dist/index.js +752 -0
  69. package/dist/issues.js +308 -0
  70. package/dist/issueweb.js +447 -0
  71. package/dist/job-cli.js +197 -0
  72. package/dist/jobtoken.js +96 -0
  73. package/dist/languages.js +383 -0
  74. package/dist/layout.js +100 -0
  75. package/dist/lfs.js +438 -0
  76. package/dist/lfsstore.js +425 -0
  77. package/dist/limit.js +259 -0
  78. package/dist/logo.js +61 -0
  79. package/dist/markdown.js +382 -0
  80. package/dist/migrate.js +334 -0
  81. package/dist/multipart.js +90 -0
  82. package/dist/ops.js +869 -0
  83. package/dist/pagescript.js +465 -0
  84. package/dist/perms.js +370 -0
  85. package/dist/pointer.js +55 -0
  86. package/dist/profile.js +106 -0
  87. package/dist/pulls.js +320 -0
  88. package/dist/pullweb.js +461 -0
  89. package/dist/redirects.js +455 -0
  90. package/dist/releases.js +435 -0
  91. package/dist/render.js +233 -0
  92. package/dist/runner/actions.js +448 -0
  93. package/dist/runner/client.js +428 -0
  94. package/dist/runner/context.js +247 -0
  95. package/dist/runner/docker.js +197 -0
  96. package/dist/runner/externals.js +175 -0
  97. package/dist/runner/job.js +290 -0
  98. package/dist/runner/manual-run.js +272 -0
  99. package/dist/runner/overrides.js +554 -0
  100. package/dist/runner/steps.js +571 -0
  101. package/dist/runner/wake.js +84 -0
  102. package/dist/runner-cli.js +405 -0
  103. package/dist/scan.js +231 -0
  104. package/dist/server.js +424 -0
  105. package/dist/session.js +267 -0
  106. package/dist/site.js +259 -0
  107. package/dist/siteshost.js +94 -0
  108. package/dist/source.js +90 -0
  109. package/dist/style.js +1295 -0
  110. package/dist/themes.js +369 -0
  111. package/dist/vault.js +442 -0
  112. package/dist/version.js +88 -0
  113. package/dist/views.js +1007 -0
  114. package/dist/web.js +182 -0
  115. package/dist/webops.js +1402 -0
  116. package/package.json +71 -0
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ // Parsing the `uses:` value of a step. Four shapes exist:
3
+ //
4
+ // actions/checkout@v4 a repository at a ref
5
+ // flatironinstitute/numbl/.github/actions/build-site@main a subdirectory of one
6
+ // ./.github/actions/thing a directory of the repository being built
7
+ // docker://alpine:3 a container image
8
+ //
9
+ // Parsing lives here, on the server side of the tree, rather than in the
10
+ // runner: the server does not resolve actions, but knowing what a workflow
11
+ // refers to is useful to it (and to any future UI that wants to say so),
12
+ // and the syntax is part of the workflow language rather than of execution.
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.ActionRefError = void 0;
15
+ exports.parseActionRef = parseActionRef;
16
+ exports.actionCacheKey = actionCacheKey;
17
+ exports.commitPrefix = commitPrefix;
18
+ exports.refIsImmutable = refIsImmutable;
19
+ class ActionRefError extends Error {
20
+ }
21
+ exports.ActionRefError = ActionRefError;
22
+ const NAME = /^[A-Za-z0-9._-]+$/;
23
+ // Refs may be branches, tags, or shas, so the character set is git's minus
24
+ // the shapes that would let one escape a path when used as a cache key.
25
+ const REF = /^[A-Za-z0-9._\-/]+$/;
26
+ function parseActionRef(uses) {
27
+ const raw = uses.trim();
28
+ if (raw === '')
29
+ throw new ActionRefError('empty uses:');
30
+ if (raw.startsWith('docker://')) {
31
+ const image = raw.slice('docker://'.length);
32
+ if (image === '' || /\s/.test(image))
33
+ throw new ActionRefError(`invalid docker image in uses: ${raw}`);
34
+ return { kind: 'docker', image, raw };
35
+ }
36
+ if (raw.startsWith('./') || raw.startsWith('.\\')) {
37
+ const p = raw.replace(/\\/g, '/').replace(/^\.\//, '');
38
+ if (p === '' || p.split('/').some((seg) => seg === '' || seg === '.' || seg === '..')) {
39
+ throw new ActionRefError(`invalid local action path in uses: ${raw}`);
40
+ }
41
+ return { kind: 'local', path: p, raw };
42
+ }
43
+ const at = raw.lastIndexOf('@');
44
+ if (at === -1) {
45
+ throw new ActionRefError(`uses: ${raw} has no version; an action reference needs @ref (for example actions/checkout@v4)`);
46
+ }
47
+ const ref = raw.slice(at + 1);
48
+ const pathPart = raw.slice(0, at);
49
+ if (!REF.test(ref) || ref.includes('..'))
50
+ throw new ActionRefError(`invalid ref in uses: ${raw}`);
51
+ const segs = pathPart.split('/');
52
+ if (segs.length < 2)
53
+ throw new ActionRefError(`uses: ${raw} is not owner/repo[/path]@ref`);
54
+ const [owner, repo, ...rest] = segs;
55
+ if (!NAME.test(owner) || !NAME.test(repo))
56
+ throw new ActionRefError(`invalid owner or repository in uses: ${raw}`);
57
+ if (rest.some((s) => s === '' || s === '.' || s === '..' || !NAME.test(s))) {
58
+ throw new ActionRefError(`invalid path in uses: ${raw}`);
59
+ }
60
+ return { kind: 'repo', owner, repo, subpath: rest.join('/'), ref, raw };
61
+ }
62
+ // A stable, filesystem-safe key for an action, used both as a cache
63
+ // directory name and as the directory the action is copied to inside a job's
64
+ // container. Slashes in a ref (release/v1) become a safe separator. When the
65
+ // commit a ref names is known the key includes it, so the entry identifies
66
+ // the bytes rather than a name that moves; the ref stays in the key as well,
67
+ // since a listing of the cache is easier to read that way, and it gives the
68
+ // runner a prefix to prune when the ref moves on.
69
+ function actionCacheKey(ref, commit) {
70
+ if (ref.kind === 'repo') {
71
+ return `${commitPrefix(ref)}${commit ? `__${commit.slice(0, 12)}` : ''}`;
72
+ }
73
+ if (ref.kind === 'local')
74
+ return `local__${ref.path.replace(/\//g, '--')}`;
75
+ return `docker__${ref.image.replace(/[^A-Za-z0-9._-]/g, '-')}`;
76
+ }
77
+ // The part of a cache key that a ref shares with every commit it has ever
78
+ // pointed at.
79
+ function commitPrefix(ref) {
80
+ return `${ref.owner}__${ref.repo}__${ref.ref.replace(/\//g, '--')}`;
81
+ }
82
+ // Whether a ref names an immutable object. A full sha never needs
83
+ // re-fetching; a branch does, since it moves.
84
+ function refIsImmutable(ref) {
85
+ return ref.kind === 'repo' && /^[0-9a-f]{40}$/i.test(ref.ref);
86
+ }