@sous-io/sous 0.2.37 → 1.0.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 (244) hide show
  1. package/README.md +14 -256
  2. package/dist/bin.js +11 -0
  3. package/dist/sous.js +1093 -0
  4. package/docs/markdown/README.md +5 -4
  5. package/docs/markdown/_sidebar.md +21 -1
  6. package/docs/markdown/commands.md +294 -431
  7. package/docs/markdown/config-discovery.md +25 -14
  8. package/docs/markdown/config-inspection.md +53 -31
  9. package/docs/markdown/config-layers.md +168 -66
  10. package/docs/markdown/config-variables.md +44 -11
  11. package/docs/markdown/configuration.md +104 -17
  12. package/docs/markdown/design-principles.md +4 -1
  13. package/docs/markdown/repositories-authoring.md +30 -0
  14. package/docs/markdown/repositories-consuming.md +72 -14
  15. package/docs/markdown/repositories-file-formats.md +31 -13
  16. package/docs/markdown/repositories-providers.md +48 -57
  17. package/docs/markdown/repositories-quickstart.md +3 -2
  18. package/docs/markdown/repositories-troubleshooting.md +27 -1
  19. package/docs/markdown/repositories-variables.md +6 -1
  20. package/docs/markdown/repositories.md +18 -8
  21. package/package.json +48 -107
  22. package/recipes/core/sous-skills/skills/about-liquid-templates/SKILL.tpl.md +4 -6
  23. package/recipes/core/sous-skills/skills/about-liquid-templates/references/liquid-filters.tpl.md +2 -0
  24. package/recipes/core/sous-skills/skills/about-sous/SKILL.tpl.md +10 -9
  25. package/recipes/core/sous-skills/skills/about-sous-configuration/SKILL.tpl.md +35 -14
  26. package/recipes/core/sous-skills/skills/about-sous-recipes/SKILL.tpl.md +51 -20
  27. package/recipes/core/sous-skills/sous.recipe.yaml +1 -1
  28. package/sous.config.schema.json +351 -132
  29. package/bin/run.js +0 -51
  30. package/src/base-command.ts +0 -457
  31. package/src/commands/build.ts +0 -181
  32. package/src/commands/clear.ts +0 -79
  33. package/src/commands/compile.ts +0 -155
  34. package/src/commands/config/get.ts +0 -110
  35. package/src/commands/config/show.ts +0 -32
  36. package/src/commands/config/validate.ts +0 -53
  37. package/src/commands/help.ts +0 -46
  38. package/src/commands/init.ts +0 -289
  39. package/src/commands/launch.ts +0 -139
  40. package/src/commands/lock/rebuild.ts +0 -239
  41. package/src/commands/lock/show.ts +0 -115
  42. package/src/commands/namespace/list.ts +0 -138
  43. package/src/commands/namespace/show.ts +0 -130
  44. package/src/commands/prune.ts +0 -43
  45. package/src/commands/recipe/list.ts +0 -112
  46. package/src/commands/recipe/show.ts +0 -439
  47. package/src/commands/repo/add.ts +0 -145
  48. package/src/commands/repo/contribute.ts +0 -604
  49. package/src/commands/repo/gc.ts +0 -173
  50. package/src/commands/repo/init.ts +0 -136
  51. package/src/commands/repo/link.ts +0 -899
  52. package/src/commands/repo/list.ts +0 -236
  53. package/src/commands/repo/release.ts +0 -685
  54. package/src/commands/repo/remove.ts +0 -194
  55. package/src/commands/repo/search.ts +0 -243
  56. package/src/commands/repo/submit.ts +0 -341
  57. package/src/commands/repo/unlink.ts +0 -461
  58. package/src/commands/subscription/add.ts +0 -286
  59. package/src/commands/subscription/list.ts +0 -208
  60. package/src/commands/subscription/remove.ts +0 -182
  61. package/src/commands/subscription/update.ts +0 -216
  62. package/src/commands/update.ts +0 -178
  63. package/src/commands/vars/ask.ts +0 -417
  64. package/src/commands/vars/index.ts +0 -79
  65. package/src/commands/vars/list.ts +0 -67
  66. package/src/commands/vars/show.ts +0 -77
  67. package/src/config-command.ts +0 -30
  68. package/src/lib/build-preparation.ts +0 -128
  69. package/src/lib/build-service.ts +0 -580
  70. package/src/lib/config-discovery.ts +0 -378
  71. package/src/lib/config-inspect.ts +0 -145
  72. package/src/lib/config-kernel.mjs +0 -379
  73. package/src/lib/config-schema.ts +0 -401
  74. package/src/lib/env-file.ts +0 -328
  75. package/src/lib/env-local.ts +0 -212
  76. package/src/lib/errors.ts +0 -32
  77. package/src/lib/glob-pattern.ts +0 -24
  78. package/src/lib/include-resolver.ts +0 -523
  79. package/src/lib/interactive.ts +0 -165
  80. package/src/lib/markdown-compiler.ts +0 -947
  81. package/src/lib/package-info.ts +0 -25
  82. package/src/lib/pid-service.ts +0 -99
  83. package/src/lib/project-install.d.mts +0 -44
  84. package/src/lib/project-install.mjs +0 -234
  85. package/src/lib/project-scaffold/index.ts +0 -332
  86. package/src/lib/project-scaffold/templates.ts +0 -240
  87. package/src/lib/repos/catalog-display.ts +0 -215
  88. package/src/lib/repos/catalog-inputs.ts +0 -288
  89. package/src/lib/repos/catalog.ts +0 -842
  90. package/src/lib/repos/contribute.ts +0 -452
  91. package/src/lib/repos/core-recipe.ts +0 -105
  92. package/src/lib/repos/declarations.ts +0 -187
  93. package/src/lib/repos/defaults.ts +0 -175
  94. package/src/lib/repos/formats/common.ts +0 -440
  95. package/src/lib/repos/formats/index-file.ts +0 -253
  96. package/src/lib/repos/formats/links-map.ts +0 -98
  97. package/src/lib/repos/formats/lockfile.ts +0 -169
  98. package/src/lib/repos/formats/patterns.ts +0 -57
  99. package/src/lib/repos/formats/recipe-manifest.ts +0 -205
  100. package/src/lib/repos/formats/repo-manifest.ts +0 -97
  101. package/src/lib/repos/formats/store-entry.ts +0 -84
  102. package/src/lib/repos/formats/variable-definition.ts +0 -268
  103. package/src/lib/repos/freshness.ts +0 -264
  104. package/src/lib/repos/git-clone.ts +0 -850
  105. package/src/lib/repos/identity.ts +0 -89
  106. package/src/lib/repos/index.ts +0 -57
  107. package/src/lib/repos/links.ts +0 -356
  108. package/src/lib/repos/load-manifest.ts +0 -237
  109. package/src/lib/repos/lock-service.ts +0 -454
  110. package/src/lib/repos/locked-namespace-resolver.ts +0 -232
  111. package/src/lib/repos/locked-recipe-lookup.ts +0 -123
  112. package/src/lib/repos/locked-recipes.ts +0 -254
  113. package/src/lib/repos/managed-layer.ts +0 -422
  114. package/src/lib/repos/memories-hash-name.ts +0 -33
  115. package/src/lib/repos/namespace-resolver.ts +0 -527
  116. package/src/lib/repos/providers/base.ts +0 -268
  117. package/src/lib/repos/providers/git.ts +0 -245
  118. package/src/lib/repos/providers/github.ts +0 -589
  119. package/src/lib/repos/providers/gitlab.ts +0 -332
  120. package/src/lib/repos/providers/http.ts +0 -128
  121. package/src/lib/repos/providers/index-cache.ts +0 -421
  122. package/src/lib/repos/providers/index.ts +0 -106
  123. package/src/lib/repos/providers/local.ts +0 -410
  124. package/src/lib/repos/providers/provider.ts +0 -615
  125. package/src/lib/repos/recipe-config-layers.ts +0 -316
  126. package/src/lib/repos/recipe-key-matcher.ts +0 -62
  127. package/src/lib/repos/recipe-memories.ts +0 -178
  128. package/src/lib/repos/recipe-targets.ts +0 -236
  129. package/src/lib/repos/ref-search.ts +0 -46
  130. package/src/lib/repos/release/bump.ts +0 -161
  131. package/src/lib/repos/release/changelog.ts +0 -461
  132. package/src/lib/repos/release/git-state.ts +0 -460
  133. package/src/lib/repos/release/index-builder.ts +0 -1108
  134. package/src/lib/repos/release/index.ts +0 -19
  135. package/src/lib/repos/release/plan.ts +0 -521
  136. package/src/lib/repos/release/settle.ts +0 -154
  137. package/src/lib/repos/release/submissions.ts +0 -214
  138. package/src/lib/repos/release/submit-checkout.ts +0 -290
  139. package/src/lib/repos/release/submit-questions.ts +0 -153
  140. package/src/lib/repos/release/submit-service.ts +0 -898
  141. package/src/lib/repos/release/tags.ts +0 -239
  142. package/src/lib/repos/release/validate.ts +0 -463
  143. package/src/lib/repos/resolver.ts +0 -1028
  144. package/src/lib/repos/scaffold/index.ts +0 -245
  145. package/src/lib/repos/scaffold/templates.ts +0 -517
  146. package/src/lib/repos/seed.ts +0 -473
  147. package/src/lib/repos/store/contract.ts +0 -64
  148. package/src/lib/repos/store/hash.ts +0 -191
  149. package/src/lib/repos/store/recipe-store.ts +0 -599
  150. package/src/lib/repos/store/settings.ts +0 -58
  151. package/src/lib/repos/subscription-service.ts +0 -3859
  152. package/src/lib/repos/trust.ts +0 -447
  153. package/src/lib/repos/update-plan.ts +0 -235
  154. package/src/lib/self-update/index.ts +0 -14
  155. package/src/lib/self-update/installs.ts +0 -413
  156. package/src/lib/self-update/managers.ts +0 -126
  157. package/src/lib/self-update/plan.ts +0 -315
  158. package/src/lib/self-update/registry.ts +0 -99
  159. package/src/lib/self-update/run.ts +0 -506
  160. package/src/lib/self-update/versions.ts +0 -243
  161. package/src/lib/settings.ts +0 -1107
  162. package/src/lib/sous-home.ts +0 -104
  163. package/src/lib/state.ts +0 -167
  164. package/src/lib/vars/answers.ts +0 -192
  165. package/src/lib/vars/ask.ts +0 -1152
  166. package/src/lib/vars/definition-source.ts +0 -261
  167. package/src/lib/vars/display.ts +0 -231
  168. package/src/lib/vars/index.ts +0 -20
  169. package/src/lib/vars/ladder.ts +0 -282
  170. package/src/lib/vars/mappings.ts +0 -260
  171. package/src/lib/vars/names.ts +0 -94
  172. package/src/lib/vars/preanswers.ts +0 -395
  173. package/src/lib/vars/question-plan.ts +0 -241
  174. package/src/lib/vars/report.ts +0 -228
  175. package/src/lib/vars/safe-regex.ts +0 -235
  176. package/src/lib/vars/secrets.ts +0 -131
  177. package/src/lib/vars/validate.ts +0 -312
  178. package/src/lib/version-report.ts +0 -90
  179. package/src/lib/watch-loop.ts +0 -148
  180. package/src/lib/watch-service.ts +0 -116
  181. package/src/services/ref-resolver/container.ts +0 -107
  182. package/src/services/ref-resolver/dependency.ts +0 -60
  183. package/src/services/ref-resolver/format.ts +0 -197
  184. package/src/services/ref-resolver/glob.ts +0 -115
  185. package/src/services/ref-resolver/hash-names.ts +0 -155
  186. package/src/services/ref-resolver/index.ts +0 -55
  187. package/src/services/ref-resolver/injectable.ts +0 -36
  188. package/src/services/ref-resolver/location.ts +0 -62
  189. package/src/services/ref-resolver/lookups/cached-index-lookup.ts +0 -53
  190. package/src/services/ref-resolver/lookups/catalog-lookup.ts +0 -23
  191. package/src/services/ref-resolver/lookups/catalog-matcher.ts +0 -261
  192. package/src/services/ref-resolver/lookups/chained-lookup.ts +0 -27
  193. package/src/services/ref-resolver/lookups/env-var-lookup.ts +0 -65
  194. package/src/services/ref-resolver/lookups/fetched-index-lookup.ts +0 -150
  195. package/src/services/ref-resolver/lookups/recorded-dependency-lookup.ts +0 -62
  196. package/src/services/ref-resolver/lookups/ref-lookup.ts +0 -54
  197. package/src/services/ref-resolver/lookups/variable-lookup.ts +0 -123
  198. package/src/services/ref-resolver/named-refs.ts +0 -144
  199. package/src/services/ref-resolver/parser/env-var-splitter.ts +0 -27
  200. package/src/services/ref-resolver/parser/location-splitter.ts +0 -239
  201. package/src/services/ref-resolver/parser/name-path-splitter.ts +0 -200
  202. package/src/services/ref-resolver/parser/partial-ref.ts +0 -84
  203. package/src/services/ref-resolver/parser/query-splitter.ts +0 -61
  204. package/src/services/ref-resolver/parser/range-splitter.ts +0 -52
  205. package/src/services/ref-resolver/parser/ref-parser.ts +0 -115
  206. package/src/services/ref-resolver/parser/repo-qualifier-splitter.ts +0 -51
  207. package/src/services/ref-resolver/parts.ts +0 -115
  208. package/src/services/ref-resolver/pruners/command-line-pruner.ts +0 -47
  209. package/src/services/ref-resolver/pruners/include-pruner.ts +0 -66
  210. package/src/services/ref-resolver/pruners/manifest-pruner.ts +0 -130
  211. package/src/services/ref-resolver/pruners/ref-pruner.ts +0 -135
  212. package/src/services/ref-resolver/pruners/rule-helpers.ts +0 -44
  213. package/src/services/ref-resolver/pruners/stored-key-pruner.ts +0 -136
  214. package/src/services/ref-resolver/ref-helpers.ts +0 -62
  215. package/src/services/ref-resolver/ref-picker-service.ts +0 -204
  216. package/src/services/ref-resolver/ref-report.ts +0 -84
  217. package/src/services/ref-resolver/ref-resolve-arguments.ts +0 -47
  218. package/src/services/ref-resolver/ref-resolve-result.ts +0 -36
  219. package/src/services/ref-resolver/ref-resolver-service.ts +0 -323
  220. package/src/services/ref-resolver/source.ts +0 -48
  221. package/src/services/ref-resolver/tokens.ts +0 -25
  222. package/src/services/ref-resolver/types.ts +0 -155
  223. package/src/templating/filters/bullet-list.ts +0 -9
  224. package/src/templating/filters/index.ts +0 -8
  225. package/src/templating/init-liquid-engine.ts +0 -139
  226. package/src/templating/lib/glob-files.ts +0 -74
  227. package/src/templating/lib/import-export.ts +0 -32
  228. package/src/templating/lib/secret-scope.ts +0 -41
  229. package/src/templating/lib/tag-args.ts +0 -19
  230. package/src/templating/tags/exportScalarVarsJs.ts +0 -46
  231. package/src/templating/tags/getFiles.ts +0 -89
  232. package/src/templating/tags/index.ts +0 -14
  233. package/src/templating/tags/listFiles.ts +0 -54
  234. package/src/templating/tags/showVars.ts +0 -28
  235. package/src/utils/choice-prompt.ts +0 -143
  236. package/src/utils/command-errors.ts +0 -186
  237. package/src/utils/command-help.ts +0 -45
  238. package/src/utils/confirm-prompt.ts +0 -110
  239. package/src/utils/flags.ts +0 -177
  240. package/src/utils/formatting.ts +0 -849
  241. package/src/utils/prompts.ts +0 -53
  242. package/src/utils/sous-directory.ts +0 -245
  243. package/src/utils/table.ts +0 -603
  244. package/src/utils/value-prompt.ts +0 -119
@@ -1,48 +0,0 @@
1
- /**
2
- * Where a ref was written. The parser reads every form wherever a ref comes
3
- * from, and the place decides which of those forms it allows: the pruner for
4
- * that place drops the readings it refuses, saying what to write there instead.
5
- */
6
- export enum RefSource {
7
- /**
8
- * A ref typed on the command line. Every form is allowed: a bare name, a
9
- * namespace and recipe, a `repo:` qualifier, a version range, a
10
- * provider-scheme locator, an HTTPS, SSH or scheme-less URL, and a browser
11
- * URL copied from a host's file view. Names may be written in any case.
12
- */
13
- CommandLine = "commandLine",
14
- /**
15
- * A subscription key in a config layer. Only the stored form is allowed:
16
- * `namespace` or `namespace/recipe`, lowercase. The repository a
17
- * subscription resolves into is recorded in the lockfile, and its range in
18
- * the entry's own `range` field.
19
- */
20
- Config = "config",
21
- /**
22
- * An entry of a recipe manifest's `depends` or `subscribes` list. A bare ref
23
- * names a recipe in the same repository; every locator and URL form names
24
- * one in another repository. A `repo:` qualifier is refused, because it is
25
- * one project's private name for a repository, and so is a local path.
26
- */
27
- Manifest = "manifest",
28
- /**
29
- * A key sous wrote itself: the lockfile, the index and the store. Only the
30
- * canonical `namespace` or `namespace/recipe` is allowed.
31
- */
32
- Lockfile = "lockfile",
33
- /**
34
- * The path of a template include line, once its sigil is taken off. Only a
35
- * file inside a recipe is allowed (`namespace/recipe/path`), and the path may
36
- * be a glob.
37
- */
38
- Include = "include",
39
- }
40
-
41
- /** What each place is called in a sentence. */
42
- export const SOURCE_LABELS: Record<RefSource, string> = {
43
- [RefSource.CommandLine]: "on the command line",
44
- [RefSource.Config]: "as a subscription key in a config file",
45
- [RefSource.Manifest]: "in a recipe manifest's 'depends' or 'subscribes' list",
46
- [RefSource.Lockfile]: "as a key sous stores",
47
- [RefSource.Include]: "in an include line",
48
- };
@@ -1,25 +0,0 @@
1
- /**
2
- * The Inversify tokens of the ref services, in one place. A plugin adds a
3
- * splitter, a pruner or a provider by binding one more value under the matching
4
- * token; nothing else in the module needs to change.
5
- */
6
-
7
- /** Every token the ref services are bound under. */
8
- export const REF_TOKENS = {
9
- /** A `RefSplitter`; bound once per splitter, injected as a list. */
10
- Splitter: Symbol.for("sous.ref.Splitter"),
11
- /** A `RefPruner`; bound once per pruner, injected as a list. */
12
- Pruner: Symbol.for("sous.ref.Pruner"),
13
- /** A `RepoProvider`; bound once per provider, injected as a list. */
14
- Provider: Symbol.for("sous.ref.Provider"),
15
- /** A `HashName`; bound once per `#` name, injected as a list. */
16
- HashName: Symbol.for("sous.ref.HashName"),
17
- /** The `HashNameRegistry`. */
18
- HashNames: Symbol.for("sous.ref.HashNames"),
19
- /** The `RefParser`. */
20
- Parser: Symbol.for("sous.ref.Parser"),
21
- /** The `RefResolverService`. */
22
- Resolver: Symbol.for("sous.ref.Resolver"),
23
- /** The `RefPickerService`. */
24
- Picker: Symbol.for("sous.ref.Picker"),
25
- } as const;
@@ -1,155 +0,0 @@
1
- /**
2
- * What a ref is: plain data, never a class instance, so it survives a JSON
3
- * round trip, can be compared structurally and can be extended by a plugin.
4
- *
5
- * A ref is a discriminated union on `kind`. Every kind with parents nests them:
6
- * a recipe file carries its recipe, which carries its namespace, which carries
7
- * the repository qualifier it was written with. A parent is optional wherever
8
- * the written form may leave it out (a bare `task-files` is a recipe whose
9
- * namespace is unknown), and a parent is a candidate of its own only when the
10
- * written text could mean it.
11
- *
12
- * Globs are a flag on the ref (`glob`), not a kind of their own: a glob is a
13
- * way of writing the name or path of a namespace, a recipe or a file, and the
14
- * kind is what a lookup needs to know where to search. `glob` is true when any
15
- * name or path part of the ref (a parent's included) is a pattern.
16
- */
17
-
18
- import type { ProviderId } from "../../lib/repos/providers/index.js";
19
-
20
- /** Where a ref says a repository lives. */
21
- export type RefLocation = {
22
- /** The provider that reads the location. */
23
- provider: ProviderId;
24
- /** The host, such as `github.com`. */
25
- host: string;
26
- /** The repository's path on the host, such as `sous-io/sous-recipes`. */
27
- repoPath: string;
28
- /** The repository's canonical identity, as the store and the lockfile key it. */
29
- identity: string;
30
- /** The repository's HTTPS URL, which is what adding it is handed. */
31
- url: string;
32
- };
33
-
34
- /** What every ref may carry. */
35
- export type RefBase = {
36
- /** True when any name or path part of the ref is a glob pattern. */
37
- glob?: true;
38
- /** The `?name=value` pairs the ref was written with, percent-decoded. */
39
- vars?: Record<string, string>;
40
- /**
41
- * What the publisher says the thing is, in one line. Never read from written
42
- * text; a lookup fills it in so a person choosing between matches can tell
43
- * them apart.
44
- */
45
- description?: string;
46
- };
47
-
48
- /**
49
- * A repository: named by the short name a project gave it, by where it lives,
50
- * or both. As the parent of another ref it is the repository qualifier.
51
- */
52
- export type RepoRef = RefBase & {
53
- kind: "repo";
54
- /** The project's short name for the repository (may be a glob). */
55
- name?: string;
56
- /** Where the repository lives, when the ref said so. */
57
- location?: RefLocation;
58
- /** A branch or tag, once a lookup has told it apart from the path after it. */
59
- revision?: string;
60
- /**
61
- * A folder or file path copied from a host's file view, branch still in
62
- * front of it (`main/recipes/workflow/alpha`). Which recipe or namespace it
63
- * is, and where the branch ends, only the repository's index can say.
64
- */
65
- browsed?: string;
66
- /** The version range a browsed path was written with; it applies to the recipe it settles to. */
67
- range?: string;
68
- };
69
-
70
- /** A namespace published by a repository. */
71
- export type NamespaceRef = RefBase & {
72
- kind: "namespace";
73
- /** The namespace name (may be a glob). */
74
- name: string;
75
- /** The repository qualifier, when one was written. */
76
- repo?: RepoRef;
77
- /** True when the namespace was spelled out as `namespace/*`. */
78
- wildcard?: true;
79
- };
80
-
81
- /** A recipe published in a namespace. */
82
- export type RecipeRef = RefBase & {
83
- kind: "recipe";
84
- /** The recipe name (may be a glob). */
85
- name: string;
86
- /** The namespace, when the ref named it. */
87
- namespace?: NamespaceRef;
88
- /** The repository qualifier, set here only when there is no namespace to hold it. */
89
- repo?: RepoRef;
90
- /** The semantic version range, when one was given. */
91
- range?: string;
92
- };
93
-
94
- /** A file inside a recipe. */
95
- export type RecipeFileRef = RefBase & {
96
- kind: "recipeFile";
97
- /** The path inside the recipe, `/`-separated (may be a glob). */
98
- path: string;
99
- /** The recipe holding it. */
100
- recipe: RecipeRef;
101
- /** The semantic version range, when one was given. */
102
- range?: string;
103
- };
104
-
105
- /** A variable a recipe declares, written `namespace/recipe.variableName`. */
106
- export type VariableRef = RefBase & {
107
- kind: "variable";
108
- /** The variable's own name, as its author wrote it (may be a glob). */
109
- name: string;
110
- /** The recipe declaring it, when the ref named it. */
111
- recipe?: RecipeRef;
112
- /** The repository qualifier, set here only when there is no recipe to hold it. */
113
- repo?: RepoRef;
114
- };
115
-
116
- /** An environment variable name, held whole: it is never split into scopes. */
117
- export type EnvVarRef = RefBase & {
118
- kind: "envVar";
119
- /** The name, exactly as written. */
120
- name: string;
121
- /** The variables this name answers, once a lookup has said. */
122
- variables?: VariableRef[];
123
- };
124
-
125
- /** Anything a written ref can name. */
126
- export type SousRef =
127
- | RepoRef
128
- | NamespaceRef
129
- | RecipeRef
130
- | RecipeFileRef
131
- | VariableRef
132
- | EnvVarRef;
133
-
134
- /** Every kind, in the order matches of equal specificity are listed in. */
135
- export const REF_KINDS = [
136
- "repo",
137
- "namespace",
138
- "recipe",
139
- "recipeFile",
140
- "variable",
141
- "envVar",
142
- ] as const;
143
-
144
- /** One kind of ref. */
145
- export type RefKind = (typeof REF_KINDS)[number];
146
-
147
- /** What each kind is called in a sentence. */
148
- export const KIND_LABELS: Record<RefKind, string> = {
149
- repo: "repository",
150
- namespace: "namespace",
151
- recipe: "recipe",
152
- recipeFile: "recipe file",
153
- variable: "variable",
154
- envVar: "environment variable",
155
- };
@@ -1,9 +0,0 @@
1
- import type { Liquid } from "liquidjs";
2
-
3
- /** Converts an array to a markdown bullet list. */
4
- export function registerBulletListFilter(engine: Liquid): void {
5
- engine.registerFilter("bulletList", (items: unknown) => {
6
- if (!Array.isArray(items)) return String(items);
7
- return items.map(i => `- ${String(i)}`).join("\n");
8
- });
9
- }
@@ -1,8 +0,0 @@
1
- import type { Liquid } from "liquidjs";
2
- import { registerBulletListFilter } from "./bullet-list.js";
3
-
4
- const filterRegistrars: Array<(engine: Liquid) => void> = [
5
- registerBulletListFilter,
6
- ];
7
-
8
- export default filterRegistrars;
@@ -1,139 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { Liquid, type FS } from "liquidjs";
4
- import filterRegistrars from "./filters/index.js";
5
- import tagRegistrars from "./tags/index.js";
6
- import { setSecretNames } from "./lib/secret-scope.js";
7
- import { resolveIncludeFiles, type AliasMap, type ViewMap } from "../lib/include-resolver.js";
8
- import {
9
- formatNamespaceProblem,
10
- type NamespaceResolver,
11
- } from "../lib/repos/namespace-resolver.js";
12
-
13
- /** Options for alias-aware `{% render %}` path resolution. */
14
- export type EngineAliasOptions = {
15
- /** Resolved alias map (name → ordered base dirs). */
16
- aliases?: AliasMap;
17
- /** The files each view lists, so a render path may name `#memories/...`. */
18
- views?: ViewMap;
19
- /** Variable scope for `${var}` substitution in render paths. */
20
- scope?: Record<string, string>;
21
- /** Resolver consulted for a `~` recipe reference in a render path. */
22
- namespaceResolver?: NamespaceResolver;
23
- /**
24
- * Absolute path of the template being rendered, handed to the namespace
25
- * resolver for scoping. Nested partials fall back to the directory LiquidJS
26
- * resolves them against, which is enough to locate the owning recipe.
27
- */
28
- fromFile?: string;
29
- /**
30
- * The variable names a recipe declared `secret: true`. `{% showVars %}` and
31
- * `{% exportScalarVarsJs %}` hide them, along with anything that very probably
32
- * is a secret.
33
- */
34
- secretVariables?: Iterable<string>;
35
- };
36
-
37
- /**
38
- * A node-backed LiquidJS FS that additionally understands alias, `#` name and
39
- * recipe render paths: `{% render "#project/x.md" %}`, `{% render "@docs/y.md" %}`,
40
- * `{% render "@${var}/z.md" %}` and `{% render "~workflow/task-files/x.md" %}`.
41
- * They resolve through the same alias/`#`/recipe/var/relative candidate logic
42
- * as `@include`, and a glob renders the first file it matches. The leading `@`
43
- * is optional for a `~` or `#` path, since the sigil already marks the path as
44
- * symbolic rather than relative. Every other path uses standard root-based
45
- * resolution.
46
- *
47
- * @param opts - Alias map, variable scope, namespace resolver and including file.
48
- * @returns A LiquidJS FS implementation.
49
- */
50
- function createAliasFS(opts: EngineAliasOptions): FS {
51
- const aliases = opts.aliases ?? {};
52
- const scope = opts.scope ?? {};
53
-
54
- /**
55
- * Resolve an `@`-path, `~`-path or `#`-path to its first existing file, or
56
- * the first candidate. Returns null for ordinary paths so the caller falls
57
- * back to root-based resolution. Throws when a `~` or `#` reference resolved
58
- * to nothing and the resolver explained why, so the reason reaches the user
59
- * instead of a bare "file not found".
60
- */
61
- const resolveSymbolic = (file: string, dir: string): string | null => {
62
- const isAt = file.startsWith("@");
63
- if (!isAt && !file.startsWith("~") && !file.startsWith("#")) return null;
64
-
65
- const rawPath = isAt ? file.slice(1) : file;
66
- const { files, candidates, namespaceIssue, hashIssue } = resolveIncludeFiles(rawPath, {
67
- aliases,
68
- views: opts.views,
69
- scope,
70
- baseDir: dir,
71
- namespaceResolver: opts.namespaceResolver,
72
- fromFile: opts.fromFile ?? dir,
73
- });
74
-
75
- if (files[0] !== undefined) return files[0];
76
-
77
- if (hashIssue) {
78
- throw new Error(`Cannot render "${file}"\n ${hashIssue.split("\n").join("\n ")}`);
79
- }
80
-
81
- if (namespaceIssue) {
82
- throw new Error(
83
- `Cannot render "${file}"\n${formatNamespaceProblem(namespaceIssue)}\n tried:\n${candidates
84
- .map((c) => ` - ${c}`)
85
- .join("\n")}`
86
- );
87
- }
88
-
89
- return candidates[0] ?? null;
90
- };
91
-
92
- return {
93
- resolve(dir: string, file: string, ext: string): string {
94
- const symbolic = resolveSymbolic(file, dir);
95
- if (symbolic) return symbolic;
96
- // Standard resolution: join against the root dir, applying ext if missing.
97
- const joined = path.resolve(dir, file);
98
- if (ext && !path.extname(joined)) return joined + ext;
99
- return joined;
100
- },
101
- existsSync: (filepath: string) => fs.existsSync(filepath),
102
- exists: async (filepath: string) => fs.existsSync(filepath),
103
- readFileSync: (filepath: string) => fs.readFileSync(filepath, "utf8"),
104
- readFile: async (filepath: string) => fs.promises.readFile(filepath, "utf8"),
105
- dirname: (file: string) => path.dirname(file),
106
- sep: path.sep,
107
- };
108
- }
109
-
110
- /**
111
- * Creates a configured LiquidJS engine instance for Sous template rendering.
112
- * Registers built-in Sous filters and tags.
113
- *
114
- * @param roots - Filesystem root paths searched (in order) when resolving
115
- * `{% render %}` partials (relative paths resolve against these).
116
- * @param aliasOpts - Optional alias map, variable scope and namespace resolver,
117
- * enabling `@alias/...`, `#name/...`, `@${var}/...` and `~namespace/...` paths in
118
- * `{% render %}` (parity with `@include`).
119
- */
120
- export function createLiquidEngine(roots: string[], aliasOpts: EngineAliasOptions = {}): Liquid {
121
- const engine = new Liquid({
122
- root: roots,
123
- extname: "",
124
- strictVariables: false,
125
- strictFilters: false,
126
- fs: createAliasFS(aliasOpts),
127
- });
128
-
129
- for (const register of filterRegistrars) {
130
- register(engine);
131
- }
132
-
133
- for (const register of tagRegistrars) {
134
- register(engine);
135
- }
136
-
137
- setSecretNames(engine, aliasOpts.secretVariables ?? []);
138
- return engine;
139
- }
@@ -1,74 +0,0 @@
1
- import path from "node:path";
2
- import { glob } from "glob";
3
-
4
- /** A single file discovered by {@link globFiles}. */
5
- export interface GlobFile {
6
- /** Absolute path to the file. */
7
- path: string;
8
- /** Absolute path to the file's directory. */
9
- dir: string;
10
- /** Path relative to the search root (POSIX separators). */
11
- relPath: string;
12
- /** File's basename (e.g. "get-thing.mjs"). */
13
- name: string;
14
- }
15
-
16
- /** Options controlling a {@link globFiles} search. */
17
- export interface GlobFilesOptions {
18
- /** Absolute directory to search within. */
19
- root: string;
20
- /** Glob patterns to include. Defaults to everything (`**\/*`). */
21
- include?: string[];
22
- /** Glob patterns to exclude. */
23
- exclude?: string[];
24
- }
25
-
26
- /**
27
- * Find files under a root directory matching include globs and not matching
28
- * exclude globs. Patterns are matched relative to `root`. Results are files
29
- * only (no directories), sorted by relative path for deterministic output.
30
- *
31
- * @param options - The search root and include/exclude glob patterns.
32
- * @returns A sorted array of matched files.
33
- */
34
- export async function globFiles(options: GlobFilesOptions): Promise<GlobFile[]> {
35
- const { root } = options;
36
- const include = options.include?.length ? options.include : ["**/*"];
37
- const exclude = options.exclude ?? [];
38
-
39
- const matches = await glob(include, {
40
- cwd: root,
41
- ignore: exclude,
42
- nodir: true,
43
- dot: true,
44
- posix: true,
45
- });
46
-
47
- const unique = [...new Set(matches)].sort((a, b) => a.localeCompare(b));
48
-
49
- return unique.map((relPath) => {
50
- const absPath = path.resolve(root, relPath);
51
- return {
52
- path: absPath,
53
- dir: path.dirname(absPath),
54
- relPath,
55
- name: path.basename(absPath),
56
- };
57
- });
58
- }
59
-
60
- /**
61
- * Parse a comma-separated glob attribute (e.g. `"*.mjs, !x.mjs"`) into a
62
- * trimmed list of non-empty patterns. Returns an empty array for
63
- * undefined/blank input.
64
- *
65
- * @param value - The raw attribute string, or undefined.
66
- * @returns The parsed pattern list.
67
- */
68
- export function parseGlobList(value: string | undefined): string[] {
69
- if (!value) return [];
70
- return value
71
- .split(",")
72
- .map((p) => p.trim())
73
- .filter((p) => p.length > 0);
74
- }
@@ -1,32 +0,0 @@
1
- import { pathToFileURL } from "node:url";
2
-
3
- /**
4
- * Dynamically import a single named export from a JavaScript/ESM file.
5
- *
6
- * Used to read declarative metadata (e.g. a script's `meta` export) at compile
7
- * time. Files are expected to have NO top-level side effects — importing them
8
- * runs module-level code.
9
- *
10
- * Failures are swallowed and reported as `undefined`: a file that fails to
11
- * import, or that lacks the requested export, simply yields no value rather
12
- * than aborting the whole template render. The optional `onError` callback
13
- * receives the path and error for diagnostics.
14
- *
15
- * @param absPath - Absolute path to the file to import.
16
- * @param exportName - The named export to read (e.g. "meta"). Use "default" for the default export.
17
- * @param onError - Optional callback invoked when import or lookup fails.
18
- * @returns The exported value, or undefined on any failure.
19
- */
20
- export async function importNamedExport(
21
- absPath: string,
22
- exportName: string,
23
- onError?: (path: string, error: unknown) => void
24
- ): Promise<unknown> {
25
- try {
26
- const mod = await import(pathToFileURL(absPath).href);
27
- return mod[exportName];
28
- } catch (error) {
29
- onError?.(absPath, error);
30
- return undefined;
31
- }
32
- }
@@ -1,41 +0,0 @@
1
- import type { Liquid } from "liquidjs";
2
- import { HIDDEN_VALUE, isSecretVariable } from "../../lib/vars/secrets.js";
3
-
4
- /**
5
- * The variable names each engine was told are secret. Kept beside the engine
6
- * rather than in its scope, so the list itself never shows up in a dump.
7
- */
8
- const secretNamesByEngine = new WeakMap<Liquid, ReadonlySet<string>>();
9
-
10
- /**
11
- * Records the variable names a recipe declared `secret: true` for one engine.
12
- *
13
- * @param engine - The engine the tags render with.
14
- * @param names - The declared names.
15
- */
16
- export function setSecretNames(engine: Liquid, names: Iterable<string>): void {
17
- secretNamesByEngine.set(engine, new Set(names));
18
- }
19
-
20
- /**
21
- * The declared secret names for an engine; empty when none were recorded.
22
- *
23
- * @param engine - The engine the tags render with.
24
- */
25
- export function secretNamesFor(engine: Liquid): ReadonlySet<string> {
26
- return secretNamesByEngine.get(engine) ?? new Set();
27
- }
28
-
29
- /**
30
- * Whether a scope entry is a secret a whole-scope dump must not print: a
31
- * declared secret, or one the heuristic in `lib/vars/secrets.ts` recognizes.
32
- *
33
- * @param engine - The engine the tag renders with.
34
- * @param name - The variable name.
35
- * @param value - Its value.
36
- */
37
- export function isSecretEntry(engine: Liquid, name: string, value: unknown): boolean {
38
- return isSecretVariable(name, value, secretNamesFor(engine));
39
- }
40
-
41
- export { HIDDEN_VALUE };
@@ -1,19 +0,0 @@
1
- /**
2
- * Split a tag's raw `args` string into an optional leading positional
3
- * identifier and the remaining `key="value"` hash markup.
4
- *
5
- * A leading identifier is treated as the positional name ONLY when it is not
6
- * immediately followed by `=` — so `getFiles tasks root="x"` yields
7
- * `{ name: "tasks", rest: 'root="x"' }`, while `getFiles root="x"` yields
8
- * `{ name: null, rest: 'root="x"' }` (the first token is the `root` attribute).
9
- *
10
- * @param args - The raw `TagToken.args` string.
11
- * @returns The positional name (or null) and the remaining hash markup.
12
- */
13
- export function splitPositionalName(args: string): { name: string | null; rest: string } {
14
- const lead = args.match(/^\s*([a-zA-Z_][\w]*)(\s*=)?/);
15
- if (lead && !lead[2]) {
16
- return { name: lead[1], rest: args.slice(lead[0].length).trim() };
17
- }
18
- return { name: null, rest: args.trim() };
19
- }
@@ -1,46 +0,0 @@
1
- import type { Liquid } from "liquidjs";
2
- import type { Context } from "liquidjs/dist/context/context.js";
3
- import { sortObjectKeys } from "../../utils/formatting.js";
4
- import { isSecretEntry } from "../lib/secret-scope.js";
5
-
6
- /**
7
- * A "scalar" for export purposes: the value types that can be safely embedded
8
- * in a settings module and consumed at runtime without structural ambiguity.
9
- */
10
- function isScalar(value: unknown): value is string | number | boolean {
11
- return (
12
- typeof value === "string" ||
13
- typeof value === "boolean" ||
14
- (typeof value === "number" && Number.isFinite(value))
15
- );
16
- }
17
-
18
- /**
19
- * Dumps all in-scope scalar variables as an ES module default export.
20
- *
21
- * Iterates every variable currently in the LiquidJS scope, keeps only scalars
22
- * (strings, finite numbers, booleans), sorts them by key, and emits a valid
23
- * `export default { ... };` block. Objects, arrays, functions, null, undefined,
24
- * and non-finite numbers are skipped, and so is every secret (one a recipe
25
- * declared, or one that very probably is): runtime code would read a masked
26
- * value as a real one, so a secret is left out rather than hidden.
27
- *
28
- * Intended for compiling a `settings.tpl.mjs` that downstream runtime code
29
- * (e.g. browser automation scripts) imports for project configuration.
30
- */
31
- export function registerExportScalarVarsJsTag(engine: Liquid): void {
32
- engine.registerTag("exportScalarVarsJs", {
33
- render(ctx: Context) {
34
- const scope = ctx.getAll() as Record<string, unknown>;
35
- const scalars: Record<string, string | number | boolean> = {};
36
-
37
- for (const [key, value] of Object.entries(scope)) {
38
- if (isScalar(value) && !isSecretEntry(engine, key, value)) scalars[key] = value;
39
- }
40
-
41
- const sorted = sortObjectKeys(scalars);
42
- const json = JSON.stringify(sorted, null, 2);
43
- return `export default ${json};\n`;
44
- },
45
- });
46
- }