@adrifer/winix 0.2.4-preview.1 → 0.3.0-preview.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.
- package/README.md +38 -2
- package/dist/backends/windows/index.js +32 -12
- package/dist/backends/windows/lockfile.d.ts +9 -5
- package/dist/backends/windows/lockfile.js +53 -17
- package/dist/backends/windows/powershell.d.ts +6 -1
- package/dist/backends/windows/powershell.js +22 -1
- package/dist/backends/windows/wsl-setup.js +1 -0
- package/dist/cli/commands/update.js +2 -1
- package/dist/evaluator/index.js +11 -0
- package/dist/helpers/windows-repositories.d.ts +11 -0
- package/dist/helpers/windows-repositories.js +77 -0
- package/dist/helpers/windows.d.ts +5 -3
- package/dist/helpers/windows.js +7 -2
- package/dist/index.d.ts +1 -1
- package/dist/skill.js +8 -1
- package/dist/types/windows.d.ts +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -536,7 +536,8 @@ other Linux/macOS systems does not translate local paths; use Windows-reachable
|
|
|
536
536
|
absolute or environment-variable sources when generating there.
|
|
537
537
|
|
|
538
538
|
PowerShell module versions and repositories are pinned in the optional `modules`
|
|
539
|
-
section of the existing `winix-windows.lock` (lowercase
|
|
539
|
+
section of the existing `winix-windows.lock` (source-qualified lowercase keys;
|
|
540
|
+
legacy name-only pins remain readable).
|
|
540
541
|
Old package-only locks remain valid. First apply resolves missing entries;
|
|
541
542
|
subsequent applies reuse pins without querying the repository.
|
|
542
543
|
`winix update --windows` refreshes packages and modules, or pass names to update
|
|
@@ -544,7 +545,7 @@ only selected entries; `--dry` resolves without writing. Resolution errors never
|
|
|
544
545
|
replace existing pins. Network access is still needed for installation.
|
|
545
546
|
|
|
546
547
|
`windows.powershell.module(name, { repository?, dependsOn? })` defaults to
|
|
547
|
-
PSGallery, selects stable releases, and installs the exact locked version for
|
|
548
|
+
the host repository policy, otherwise PSGallery, selects stable releases, and installs the exact locked version for
|
|
548
549
|
the current user. PowerShell 7 with PSResourceGet must already be available for
|
|
549
550
|
resolution. Installation is idempotent and runs directly in DSC's
|
|
550
551
|
`Microsoft.DSC.Transitional/PowerShellScript` resource; a declared `Microsoft.PowerShell` package is an
|
|
@@ -552,6 +553,41 @@ automatic dependency. Other versions are not removed. Profiles still import
|
|
|
552
553
|
modules themselves; an unversioned `Import-Module` can load a newer installed
|
|
553
554
|
version, so installation locking alone does not enforce session imports.
|
|
554
555
|
|
|
556
|
+
Work profiles can enforce an approved feed without changing shared features:
|
|
557
|
+
|
|
558
|
+
```ts
|
|
559
|
+
const workRepositories = feature("work-repositories", ({ windows }) => {
|
|
560
|
+
windows.powershell.repositories({
|
|
561
|
+
repositories: {
|
|
562
|
+
approved: { uri: "https://packages.example.com/powershell/v3/index.json" },
|
|
563
|
+
},
|
|
564
|
+
default: "approved",
|
|
565
|
+
allowed: ["approved"],
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
const work = profile("work", [workRepositories(), windowsShell()]);
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
The policy is resolved after host fragments merge. Omitted module repositories
|
|
572
|
+
and the automatic `Microsoft.Windows.Settings` installer use its default.
|
|
573
|
+
Explicit repositories outside `allowed` fail before resolution; there is no
|
|
574
|
+
fallback. Omit `allowed` to permit explicit overrides. It governs Winix-managed
|
|
575
|
+
PowerShell installers, not raw commands, generic DSC, npm, NuGet, or WSL.
|
|
576
|
+
Personal hosts without this feature retain PSGallery.
|
|
577
|
+
Conflicting policies in one host fail instead of silently widening its allowlist.
|
|
578
|
+
|
|
579
|
+
Named feeds use HTTPS URLs without embedded credentials. Version resolution
|
|
580
|
+
registers a missing feed for the current user; activation also ensures registration
|
|
581
|
+
before module installation. A same-name registration with a different URI is an
|
|
582
|
+
error, never overwritten. Registration persists, but global priorities and permanent
|
|
583
|
+
trust are unchanged. Authenticate separately using the organization's supported
|
|
584
|
+
PSResourceGet setup; do not put secrets in config or locks. `--dry` does not write
|
|
585
|
+
the lock or activate resources, but resolving missing versions can register a feed.
|
|
586
|
+
Pins distinguish module name, repository name, and configured URI across hosts;
|
|
587
|
+
a new source resolves its own pin. Existing matching installed versions are reused,
|
|
588
|
+
not reinstalled to attest their original source. Settings retains its existing
|
|
589
|
+
prerelease ensure behavior rather than adding a stable module lock.
|
|
590
|
+
|
|
555
591
|
### Provision WSL from a Windows host
|
|
556
592
|
|
|
557
593
|
```ts
|
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
// processor is selected by the metadata block.
|
|
28
28
|
import { win32 } from "node:path";
|
|
29
29
|
import { yamlEntry, yamlScalar } from "./yaml.js";
|
|
30
|
-
import { emptyWindowsLock, reconcileInlinePins, } from "./lockfile.js";
|
|
30
|
+
import { emptyWindowsLock, reconcileInlinePins, windowsModulePin, } from "./lockfile.js";
|
|
31
31
|
import { isWindowsHost } from "./host.js";
|
|
32
32
|
import { resolveWindowsFileProperties } from "../../helpers/windows.js";
|
|
33
|
-
import { powerShellModuleProperties } from "./powershell.js";
|
|
33
|
+
import { powerShellModuleProperties, powerShellRepositoryScripts } from "./powershell.js";
|
|
34
|
+
import { powerShellRepositoryUri, resolvePowerShellModule, validateWindowsPowerShellPolicy } from "../../helpers/windows-repositories.js";
|
|
34
35
|
import { powerShellLiteral as psSingleQuoted } from "../../helpers/utils.js";
|
|
35
36
|
import { windowsSourcePath } from "./paths.js";
|
|
36
37
|
import { optionalFeatureProperties, wslDistroProperties } from "./wsl.js";
|
|
@@ -62,7 +63,23 @@ export function generateWindows(evaluatedHosts, lock = emptyWindowsLock(), confi
|
|
|
62
63
|
*/
|
|
63
64
|
function generateConfiguration(hostName, win, lock, configDir) {
|
|
64
65
|
validateWindowsWslResources(win);
|
|
66
|
+
validateWindowsPowerShellPolicy(win);
|
|
65
67
|
const packages = sortedPackages(win.packages ?? {});
|
|
68
|
+
const registrations = Object.entries(win.powershell?.repositories?.repositories ?? {}).map(([name, feed]) => {
|
|
69
|
+
const scripts = powerShellRepositoryScripts(name, powerShellRepositoryUri(feed.uri));
|
|
70
|
+
const resource = {
|
|
71
|
+
name: `Register PowerShell repository ${name}`,
|
|
72
|
+
resourceType: "Microsoft.DSC.Transitional/PowerShellScript",
|
|
73
|
+
properties: { getScript: scripts.get, testScript: scripts.test, setScript: scripts.set },
|
|
74
|
+
dependsOn: packages.filter((pkg) => pkg.id.toLowerCase() === "microsoft.powershell")
|
|
75
|
+
.map((pkg) => ({ kind: "package", id: pkg.id })),
|
|
76
|
+
};
|
|
77
|
+
Object.defineProperty(resource, "token", { value: Symbol(name), enumerable: false });
|
|
78
|
+
return { name, resource };
|
|
79
|
+
});
|
|
80
|
+
const repositoryDependencies = (repository) => registrations
|
|
81
|
+
.filter((entry) => entry.name.toLowerCase() === repository.toLowerCase())
|
|
82
|
+
.map((entry) => ({ kind: "dsc", token: entry.resource.token }));
|
|
66
83
|
const resources = (win.dsc ?? []).map((resource) => {
|
|
67
84
|
const metadata = resource.winix;
|
|
68
85
|
if (metadata?.kind === "file") {
|
|
@@ -87,12 +104,12 @@ function generateConfiguration(hostName, win, lock, configDir) {
|
|
|
87
104
|
]);
|
|
88
105
|
}
|
|
89
106
|
if (metadata?.kind === "powershell-module") {
|
|
90
|
-
const module = metadata.module;
|
|
91
|
-
const pin = lock
|
|
92
|
-
if (!pin
|
|
107
|
+
const module = resolvePowerShellModule(win, metadata.module);
|
|
108
|
+
const pin = windowsModulePin(lock, module);
|
|
109
|
+
if (!pin) {
|
|
93
110
|
throw new Error(`PowerShell module "${module.name}" has no matching pin in winix-windows.lock. Run winix update --windows.`);
|
|
94
111
|
}
|
|
95
|
-
const dependencies = [...(resource.dependsOn ?? [])];
|
|
112
|
+
const dependencies = [...repositoryDependencies(module.repository), ...(resource.dependsOn ?? [])];
|
|
96
113
|
if (packages.some((pkg) => pkg.id === "Microsoft.PowerShell") &&
|
|
97
114
|
!dependencies.some((ref) => ref.kind === "package" && ref.id === "Microsoft.PowerShell")) {
|
|
98
115
|
dependencies.push({ kind: "package", id: "Microsoft.PowerShell" });
|
|
@@ -101,9 +118,10 @@ function generateConfiguration(hostName, win, lock, configDir) {
|
|
|
101
118
|
}
|
|
102
119
|
return resource;
|
|
103
120
|
});
|
|
104
|
-
const
|
|
121
|
+
const settingsModule = resolvePowerShellModule(win, { name: "Microsoft.Windows.Settings" });
|
|
122
|
+
const prepared = prepareWindowsDscResources(win.commands ?? [], resources, settingsModule.repository, repositoryDependencies(settingsModule.repository));
|
|
105
123
|
const commands = prepared.commands;
|
|
106
|
-
const dscResources = prepared.dscResources;
|
|
124
|
+
const dscResources = [...registrations.map((entry) => entry.resource), ...prepared.dscResources];
|
|
107
125
|
const lines = [];
|
|
108
126
|
lines.push(`# yaml-language-server: $schema=${DSC_SCHEMA}`);
|
|
109
127
|
lines.push(`# Generated by Winix for host "${hostName}". Do not edit.`);
|
|
@@ -184,12 +202,12 @@ export function validateWindowsWslResources(win) {
|
|
|
184
202
|
throw new Error('WSL distro provisioning requires windows.package("Microsoft.WSL")');
|
|
185
203
|
}
|
|
186
204
|
}
|
|
187
|
-
function prepareWindowsDscResources(commands, resources) {
|
|
205
|
+
function prepareWindowsDscResources(commands, resources, settingsRepository, repositoryDependencies) {
|
|
188
206
|
const envResolvedResources = resolveManagedEnvironmentReferences(resources);
|
|
189
207
|
if (!envResolvedResources.some((resource) => resource.winix?.kind === "setting")) {
|
|
190
208
|
return { commands: [...commands], dscResources: envResolvedResources };
|
|
191
209
|
}
|
|
192
|
-
const ensureModule = createWindowsSettingsEnsureCommand();
|
|
210
|
+
const ensureModule = createWindowsSettingsEnsureCommand(settingsRepository, repositoryDependencies);
|
|
193
211
|
const ensureRef = { kind: "dsc", token: ensureModule.token };
|
|
194
212
|
return {
|
|
195
213
|
commands: [...commands],
|
|
@@ -206,7 +224,7 @@ function prepareWindowsDscResources(commands, resources) {
|
|
|
206
224
|
],
|
|
207
225
|
};
|
|
208
226
|
}
|
|
209
|
-
function createWindowsSettingsEnsureCommand() {
|
|
227
|
+
function createWindowsSettingsEnsureCommand(repository, dependsOn) {
|
|
210
228
|
// Microsoft.Windows.Settings currently publishes the WindowsSettings resource
|
|
211
229
|
// as a prerelease module (the upstream sample uses v0.1.0-alpha), so the
|
|
212
230
|
// ensure step must opt into prerelease discovery for now. Revisit/remove
|
|
@@ -214,6 +232,7 @@ function createWindowsSettingsEnsureCommand() {
|
|
|
214
232
|
const resource = {
|
|
215
233
|
name: WINDOWS_SETTINGS_MODULE_COMMAND_NAME,
|
|
216
234
|
resourceType: RUN_COMMAND_ON_SET_TYPE,
|
|
235
|
+
dependsOn,
|
|
217
236
|
properties: {
|
|
218
237
|
executable: "pwsh",
|
|
219
238
|
arguments: {
|
|
@@ -223,7 +242,8 @@ function createWindowsSettingsEnsureCommand() {
|
|
|
223
242
|
"3": [
|
|
224
243
|
"$ErrorActionPreference = 'Stop';",
|
|
225
244
|
"if (-not (Get-Module -ListAvailable -Name Microsoft.Windows.Settings)) {",
|
|
226
|
-
|
|
245
|
+
` Install-PSResource -Name Microsoft.Windows.Settings -Repository ${psSingleQuoted(repository)} -Scope CurrentUser -Prerelease -TrustRepository -AcceptLicense -ErrorAction Stop | Out-Null;`,
|
|
246
|
+
" if (-not (Get-Module -ListAvailable -Name Microsoft.Windows.Settings)) { throw 'Microsoft.Windows.Settings was not installed' }",
|
|
227
247
|
"}",
|
|
228
248
|
].join(" "),
|
|
229
249
|
treatAsArray: true,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { EvaluatedHost } from "../../evaluator/index.js";
|
|
2
|
-
import type { WinPackage, WinPackageSource
|
|
2
|
+
import type { WinPackage, WinPackageSource } from "../../types/index.js";
|
|
3
3
|
import { type WslArchitecture, type WindowsWslImageResolver } from "./wsl.js";
|
|
4
4
|
import { type WindowsLockWslRepository, type WindowsWslRepositoryResolver } from "./wsl-setup.js";
|
|
5
|
+
import { type ResolvedPowerShellModule } from "../../helpers/windows-repositories.js";
|
|
5
6
|
export declare const WINDOWS_LOCKFILE_NAME = "winix-windows.lock";
|
|
6
7
|
export declare const WINDOWS_LOCK_VERSION = 1;
|
|
7
8
|
export interface WindowsLockPackage {
|
|
@@ -13,7 +14,7 @@ export interface WindowsLock {
|
|
|
13
14
|
version: typeof WINDOWS_LOCK_VERSION;
|
|
14
15
|
generatedAt: string;
|
|
15
16
|
packages: Record<string, WindowsLockPackage>;
|
|
16
|
-
/**
|
|
17
|
+
/** Source-qualified lowercase keys; legacy name-only entries remain readable. */
|
|
17
18
|
modules?: Record<string, WindowsLockModule>;
|
|
18
19
|
wslImages?: Record<string, WindowsLockWslImage>;
|
|
19
20
|
wslRepositories?: Record<string, WindowsLockWslRepository>;
|
|
@@ -28,10 +29,13 @@ export interface WindowsLockWslImage {
|
|
|
28
29
|
}
|
|
29
30
|
export interface WindowsLockModule {
|
|
30
31
|
repository: string;
|
|
32
|
+
repositoryUri?: string;
|
|
31
33
|
version: string;
|
|
32
34
|
resolvedAt: string;
|
|
33
35
|
}
|
|
34
|
-
export type WindowsModuleVersionResolver = (name: string, repository: string) => string;
|
|
36
|
+
export type WindowsModuleVersionResolver = (name: string, repository: string, repositoryUri?: string) => string;
|
|
37
|
+
export declare function windowsModuleKey(module: ResolvedPowerShellModule): string;
|
|
38
|
+
export declare function windowsModulePin(lock: WindowsLock, module: ResolvedPowerShellModule): WindowsLockModule | undefined;
|
|
35
39
|
export type WindowsPackageVersionResolver = (id: string, source: WinPackageSource) => string;
|
|
36
40
|
export interface WindowsLockResolution {
|
|
37
41
|
id: string;
|
|
@@ -53,7 +57,7 @@ export declare function resolveMissingWindowsLockEntries(lock: WindowsLock, eval
|
|
|
53
57
|
export declare function resolveWindowsLockEntries(lock: WindowsLock, packages: Iterable<WinPackage>, resolveVersion: WindowsPackageVersionResolver, now?: Date): WindowsLockResolutionResult;
|
|
54
58
|
export declare function windowsLockChanged(before: WindowsLock, after: WindowsLock): boolean;
|
|
55
59
|
export declare function serializeWindowsLock(lock: WindowsLock): string;
|
|
56
|
-
export declare function collectWindowsModules(hosts: EvaluatedHost[]): Map<string,
|
|
60
|
+
export declare function collectWindowsModules(hosts: EvaluatedHost[]): Map<string, ResolvedPowerShellModule>;
|
|
57
61
|
export declare function hasWindowsWslDistros(hosts: EvaluatedHost[]): boolean;
|
|
58
62
|
export declare function resolveWindowsWslImages(lock: WindowsLock, resolve: WindowsWslImageResolver, now?: Date, missingOnly?: boolean): {
|
|
59
63
|
lock: WindowsLock;
|
|
@@ -63,7 +67,7 @@ export declare function resolveWindowsWslRepositories(lock: WindowsLock, hosts:
|
|
|
63
67
|
lock: WindowsLock;
|
|
64
68
|
changed: boolean;
|
|
65
69
|
};
|
|
66
|
-
export declare function resolveWindowsModuleLockEntries(lock: WindowsLock, modules: Iterable<
|
|
70
|
+
export declare function resolveWindowsModuleLockEntries(lock: WindowsLock, modules: Iterable<ResolvedPowerShellModule>, resolveVersion: WindowsModuleVersionResolver, now?: Date, missingOnly?: boolean): {
|
|
67
71
|
lock: WindowsLock;
|
|
68
72
|
resolutions: Omit<WindowsLockResolution, "source">[];
|
|
69
73
|
changed: boolean;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
3
4
|
import { validWslImage } from "./wsl.js";
|
|
4
5
|
import { validWslRepository, wslRepositoryKey, } from "./wsl-setup.js";
|
|
6
|
+
import { resolvePowerShellModule, powerShellRepositoryUri, } from "../../helpers/windows-repositories.js";
|
|
5
7
|
export const WINDOWS_LOCKFILE_NAME = "winix-windows.lock";
|
|
6
8
|
export const WINDOWS_LOCK_VERSION = 1;
|
|
9
|
+
export function windowsModuleKey(module) {
|
|
10
|
+
const name = module.name.toLowerCase();
|
|
11
|
+
if (!module.repositoryUri && module.repository.toLowerCase() === "psgallery")
|
|
12
|
+
return name;
|
|
13
|
+
const source = `${name}@${module.repository.toLowerCase()}`;
|
|
14
|
+
return module.repositoryUri
|
|
15
|
+
? `${source}/${createHash("sha256").update(powerShellRepositoryUri(module.repositoryUri)).digest("hex")}`
|
|
16
|
+
: source;
|
|
17
|
+
}
|
|
18
|
+
export function windowsModulePin(lock, module) {
|
|
19
|
+
const pin = lock.modules?.[windowsModuleKey(module)] ??
|
|
20
|
+
(!module.repositoryUri ? lock.modules?.[module.name.toLowerCase()] : undefined);
|
|
21
|
+
if (pin?.repository.toLowerCase() !== module.repository.toLowerCase() ||
|
|
22
|
+
pin?.repositoryUri !== module.repositoryUri)
|
|
23
|
+
return undefined;
|
|
24
|
+
return pin;
|
|
25
|
+
}
|
|
7
26
|
export function readWindowsLock(configDir) {
|
|
8
27
|
const path = windowsLockPath(configDir);
|
|
9
28
|
if (!existsSync(path))
|
|
@@ -162,15 +181,18 @@ export function serializeWindowsLock(lock) {
|
|
|
162
181
|
export function collectWindowsModules(hosts) {
|
|
163
182
|
const modules = new Map();
|
|
164
183
|
for (const host of hosts) {
|
|
165
|
-
|
|
184
|
+
const win = host.windows;
|
|
185
|
+
const hostModules = new Map();
|
|
186
|
+
for (const resource of win.dsc ?? []) {
|
|
166
187
|
if (resource.winix?.kind !== "powershell-module")
|
|
167
188
|
continue;
|
|
168
|
-
const module = resource.winix.module;
|
|
169
|
-
const key = module
|
|
170
|
-
const existing =
|
|
171
|
-
if (existing && existing
|
|
189
|
+
const module = resolvePowerShellModule(win, resource.winix.module);
|
|
190
|
+
const key = windowsModuleKey(module);
|
|
191
|
+
const existing = hostModules.get(module.name.toLowerCase());
|
|
192
|
+
if (existing && existing !== key) {
|
|
172
193
|
throw new Error(`PowerShell module "${module.name}" is declared with conflicting repositories.`);
|
|
173
194
|
}
|
|
195
|
+
hostModules.set(module.name.toLowerCase(), key);
|
|
174
196
|
modules.set(key, module);
|
|
175
197
|
}
|
|
176
198
|
}
|
|
@@ -235,17 +257,12 @@ export function resolveWindowsModuleLockEntries(lock, modules, resolveVersion, n
|
|
|
235
257
|
const resolutions = [];
|
|
236
258
|
let changed = false;
|
|
237
259
|
for (const module of modules) {
|
|
238
|
-
const key = module
|
|
239
|
-
const previous = next
|
|
240
|
-
if (
|
|
241
|
-
if (missingOnly) {
|
|
242
|
-
throw new Error(`PowerShell module "${module.name}" changed repository. Run winix update --windows ${module.name}.`);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
else if (missingOnly && previous) {
|
|
260
|
+
const key = windowsModuleKey(module);
|
|
261
|
+
const previous = windowsModulePin(next, module);
|
|
262
|
+
if (missingOnly && previous) {
|
|
246
263
|
continue;
|
|
247
264
|
}
|
|
248
|
-
const version = resolveVersion(module.name, module.repository);
|
|
265
|
+
const version = resolveVersion(module.name, module.repository, module.repositoryUri);
|
|
249
266
|
if (!/^\d+\.\d+\.\d+(?:\.\d+)?$/.test(version)) {
|
|
250
267
|
throw new Error(`PowerShell module "${module.name}" resolver did not return a stable version: ${version}`);
|
|
251
268
|
}
|
|
@@ -257,7 +274,11 @@ export function resolveWindowsModuleLockEntries(lock, modules, resolveVersion, n
|
|
|
257
274
|
});
|
|
258
275
|
if (unchanged)
|
|
259
276
|
continue;
|
|
260
|
-
next.modules[key] = {
|
|
277
|
+
next.modules[key] = {
|
|
278
|
+
repository: module.repository,
|
|
279
|
+
...(module.repositoryUri ? { repositoryUri: module.repositoryUri } : {}),
|
|
280
|
+
version, resolvedAt: now.toISOString(),
|
|
281
|
+
};
|
|
261
282
|
next.generatedAt = now.toISOString();
|
|
262
283
|
changed = true;
|
|
263
284
|
}
|
|
@@ -312,16 +333,31 @@ function validateWindowsLock(value) {
|
|
|
312
333
|
if (!isObject(value.modules))
|
|
313
334
|
throw new Error(`${WINDOWS_LOCKFILE_NAME} modules must be an object.`);
|
|
314
335
|
for (const [name, entry] of Object.entries(value.modules)) {
|
|
315
|
-
if (!/^[a-z0-9][a-z0-9._-]
|
|
336
|
+
if (!/^[a-z0-9][a-z0-9._-]*(?:@[a-z0-9][a-z0-9._-]*(?:\/[a-f0-9]{64})?)?$/i.test(name) || !isObject(entry) ||
|
|
316
337
|
typeof entry.repository !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(entry.repository) ||
|
|
317
338
|
typeof entry.version !== "string" || !/^\d+\.\d+\.\d+(?:\.\d+)?$/.test(entry.version) ||
|
|
318
339
|
typeof entry.resolvedAt !== "string") {
|
|
319
340
|
throw new Error(`${WINDOWS_LOCKFILE_NAME} module "${name}" has an invalid repository, stable version, or resolvedAt.`);
|
|
320
341
|
}
|
|
342
|
+
if (entry.repositoryUri !== undefined &&
|
|
343
|
+
(typeof entry.repositoryUri !== "string" || powerShellRepositoryUri(entry.repositoryUri) !== entry.repositoryUri)) {
|
|
344
|
+
throw new Error(`${WINDOWS_LOCKFILE_NAME} module "${name}" has an invalid repository URI.`);
|
|
345
|
+
}
|
|
321
346
|
const key = name.toLowerCase();
|
|
347
|
+
if ((key.includes("@") || entry.repositoryUri !== undefined) &&
|
|
348
|
+
key !== windowsModuleKey({
|
|
349
|
+
name: name.split("@")[0], repository: entry.repository,
|
|
350
|
+
...(typeof entry.repositoryUri === "string" ? { repositoryUri: entry.repositoryUri } : {}),
|
|
351
|
+
})) {
|
|
352
|
+
throw new Error(`${WINDOWS_LOCKFILE_NAME} module "${name}" does not match its repository identity.`);
|
|
353
|
+
}
|
|
322
354
|
if (modules[key])
|
|
323
355
|
throw new Error(`${WINDOWS_LOCKFILE_NAME} has duplicate module "${name}".`);
|
|
324
|
-
modules[key] = {
|
|
356
|
+
modules[key] = {
|
|
357
|
+
repository: entry.repository,
|
|
358
|
+
...(typeof entry.repositoryUri === "string" ? { repositoryUri: entry.repositoryUri } : {}),
|
|
359
|
+
version: entry.version, resolvedAt: entry.resolvedAt,
|
|
360
|
+
};
|
|
325
361
|
}
|
|
326
362
|
}
|
|
327
363
|
const wslImages = {};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { WinDscProperties, WinPowerShellModule } from "../../types/index.js";
|
|
2
2
|
import type { WindowsLockModule } from "./lockfile.js";
|
|
3
|
+
export declare function powerShellRepositoryScripts(name: string, uri: string): {
|
|
4
|
+
get: string;
|
|
5
|
+
test: string;
|
|
6
|
+
set: string;
|
|
7
|
+
};
|
|
3
8
|
export type PowerShellGalleryRunner = (script: string) => string;
|
|
4
9
|
/** Find-PSResource returns the newest stable release unless -Prerelease is requested. */
|
|
5
|
-
export declare function resolvePowerShellModuleVersion(name: string, repository: string,
|
|
10
|
+
export declare function resolvePowerShellModuleVersion(name: string, repository: string, repositoryUriOrRunner?: string | PowerShellGalleryRunner, runner?: PowerShellGalleryRunner): string;
|
|
6
11
|
export declare function powerShellModuleProperties(module: WinPowerShellModule, pin: WindowsLockModule): WinDscProperties;
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
2
|
import { powerShellLiteral } from "../../helpers/utils.js";
|
|
3
|
+
export function powerShellRepositoryScripts(name, uri) {
|
|
4
|
+
const prelude = [
|
|
5
|
+
"$ErrorActionPreference = 'Stop'",
|
|
6
|
+
`$repositoryName = ${powerShellLiteral(name)}`,
|
|
7
|
+
`$repositoryUri = ${powerShellLiteral(uri)}`,
|
|
8
|
+
"$registeredRepository = @(Get-PSResourceRepository -ErrorAction Stop | Where-Object { $_.Name -ieq $repositoryName })",
|
|
9
|
+
`if ($registeredRepository.Count -gt 0 -and $registeredRepository[0].Uri.AbsoluteUri.TrimEnd('/') -cne $repositoryUri) { throw "PowerShell repository $repositoryName is already registered with a different URI; resolve the registration conflict explicitly" }`,
|
|
10
|
+
];
|
|
11
|
+
return {
|
|
12
|
+
get: [...prelude, "$registeredRepository | Select-Object Name,Uri"].join("\n"),
|
|
13
|
+
test: [...prelude, "$registeredRepository.Count -eq 1"].join("\n"),
|
|
14
|
+
set: [
|
|
15
|
+
...prelude,
|
|
16
|
+
"if ($registeredRepository.Count -eq 0) { Register-PSResourceRepository -Name $repositoryName -Uri $repositoryUri -ErrorAction Stop }",
|
|
17
|
+
].join("\n"),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
3
20
|
/** Find-PSResource returns the newest stable release unless -Prerelease is requested. */
|
|
4
|
-
export function resolvePowerShellModuleVersion(name, repository,
|
|
21
|
+
export function resolvePowerShellModuleVersion(name, repository, repositoryUriOrRunner, runner) {
|
|
22
|
+
const repositoryUri = typeof repositoryUriOrRunner === "string" ? repositoryUriOrRunner : undefined;
|
|
23
|
+
const run = (typeof repositoryUriOrRunner === "function" ? repositoryUriOrRunner : runner) ??
|
|
24
|
+
((script) => execFileSync("pwsh", ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", encode(script)], { encoding: "utf8" }));
|
|
5
25
|
const script = [
|
|
6
26
|
"$ErrorActionPreference = 'Stop'",
|
|
27
|
+
...(repositoryUri ? [powerShellRepositoryScripts(repository, repositoryUri).set] : []),
|
|
7
28
|
`$found = @(Find-PSResource -Name ${powerShellLiteral(name)} -Repository ${powerShellLiteral(repository)} -ErrorAction Stop)`,
|
|
8
29
|
`if ($found.Count -ne 1 -or $found[0].Name -ine ${powerShellLiteral(name)} -or $found[0].Prerelease) { throw 'Expected one stable module release' }`,
|
|
9
30
|
"$found[0].Version.ToString() | ConvertTo-Json -Compress",
|
|
@@ -108,6 +108,7 @@ export function wslSetupPrelude(setup, pin) {
|
|
|
108
108
|
}
|
|
109
109
|
const probe = [
|
|
110
110
|
"set -euo pipefail",
|
|
111
|
+
'export PATH="/run/current-system/sw/bin:/run/wrappers/bin${PATH:+:$PATH}"',
|
|
111
112
|
"state=/var/lib/winix/wsl-setup",
|
|
112
113
|
"[[ ! -L \"$state\" && ! -L \"$state/complete\" ]] || { echo 'Unsafe WSL setup completion record' >&2; exit 2; }",
|
|
113
114
|
"if [[ ! -f \"$state/complete\" ]]; then exit 3; fi",
|
|
@@ -78,7 +78,8 @@ async function updateWindowsLock(cwd, opts) {
|
|
|
78
78
|
const wslImages = hasWindowsWslDistros(windowsHosts);
|
|
79
79
|
const wslSetup = windowsHosts.some((host) => host.windows.dsc?.some((resource) => resource.winix?.kind === "wsl-distro" && resource.winix.distro.setup));
|
|
80
80
|
for (const id of opts.inputs) {
|
|
81
|
-
if (!floating.has(id) && !pinned.has(id) &&
|
|
81
|
+
if (!floating.has(id) && !pinned.has(id) &&
|
|
82
|
+
![...modules.values()].some((module) => module.name.toLowerCase() === id.toLowerCase()) &&
|
|
82
83
|
!(id === "nixos-wsl" && wslImages) && !(id === "wsl-setup" && wslSetup)) {
|
|
83
84
|
throw new Error(`Windows package, PowerShell module, WSL image or setup repository "${id}" is not declared in this workspace.`);
|
|
84
85
|
}
|
package/dist/evaluator/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Evaluator: takes a workspace config, evaluates fragments per host, produces merged IR
|
|
2
2
|
import { setEvalContext, restoreEvalContext } from "../sdk/index.js";
|
|
3
|
+
import { powerShellRepositoryPolicyIdentity, validateWindowsPowerShellPolicy } from "../helpers/windows-repositories.js";
|
|
3
4
|
/**
|
|
4
5
|
* Evaluate a workspace: process each host's fragments and merge them.
|
|
5
6
|
*/
|
|
@@ -50,12 +51,22 @@ function evaluateHost(host) {
|
|
|
50
51
|
result.windows = mergeWindowsOptions(result.windows, fragment.windows);
|
|
51
52
|
}
|
|
52
53
|
}
|
|
54
|
+
validateWindowsPowerShellPolicy(result.windows);
|
|
53
55
|
return result;
|
|
54
56
|
}
|
|
55
57
|
function mergeWindowsOptions(target, source) {
|
|
58
|
+
const targetPolicy = target.powershell?.repositories;
|
|
59
|
+
const sourcePolicy = source.powershell?.repositories;
|
|
60
|
+
if (targetPolicy && sourcePolicy &&
|
|
61
|
+
powerShellRepositoryPolicyIdentity(targetPolicy) !== powerShellRepositoryPolicyIdentity(sourcePolicy)) {
|
|
62
|
+
throw new Error("Conflicting PowerShell repository policies in one host; declare one policy in the selected profile");
|
|
63
|
+
}
|
|
56
64
|
const targetCommands = Array.isArray(target.commands) ? target.commands : [];
|
|
57
65
|
const sourceCommands = Array.isArray(source.commands) ? source.commands : [];
|
|
58
66
|
const result = deepMerge(target, source);
|
|
67
|
+
if (targetPolicy && sourcePolicy) {
|
|
68
|
+
result.powershell = { ...result.powershell, repositories: targetPolicy };
|
|
69
|
+
}
|
|
59
70
|
if (targetCommands.length > 0 || sourceCommands.length > 0) {
|
|
60
71
|
result.commands = [...targetCommands, ...sourceCommands];
|
|
61
72
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WinPowerShellModule, WinPowerShellRepositoryPolicy, WindowsOptions } from "../types/windows.js";
|
|
2
|
+
export interface ResolvedPowerShellModule extends WinPowerShellModule {
|
|
3
|
+
repository: string;
|
|
4
|
+
repositoryUri?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const powerShellRepositoryName: RegExp;
|
|
7
|
+
export declare function powerShellRepositoryUri(value: string): string;
|
|
8
|
+
export declare function validatePowerShellRepositoryPolicy(policy: WinPowerShellRepositoryPolicy): void;
|
|
9
|
+
export declare function powerShellRepositoryPolicyIdentity(policy: WinPowerShellRepositoryPolicy): string;
|
|
10
|
+
export declare function resolvePowerShellModule(win: WindowsOptions, module: WinPowerShellModule): ResolvedPowerShellModule;
|
|
11
|
+
export declare function validateWindowsPowerShellPolicy(win: WindowsOptions): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export const powerShellRepositoryName = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
2
|
+
export function powerShellRepositoryUri(value) {
|
|
3
|
+
let url;
|
|
4
|
+
try {
|
|
5
|
+
url = new URL(value);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
throw new Error("PowerShell repository URI must be an HTTPS URL");
|
|
9
|
+
}
|
|
10
|
+
if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash) {
|
|
11
|
+
throw new Error("PowerShell repository URI must be HTTPS without credentials, query, or fragment");
|
|
12
|
+
}
|
|
13
|
+
return url.href.replace(/\/+$/, "");
|
|
14
|
+
}
|
|
15
|
+
export function validatePowerShellRepositoryPolicy(policy) {
|
|
16
|
+
if (!policy || typeof policy !== "object" || Array.isArray(policy) ||
|
|
17
|
+
!policy.repositories || typeof policy.repositories !== "object" || Array.isArray(policy.repositories) ||
|
|
18
|
+
typeof policy.default !== "string" || !powerShellRepositoryName.test(policy.default)) {
|
|
19
|
+
throw new Error("PowerShell repository policy requires repositories and a default repository name");
|
|
20
|
+
}
|
|
21
|
+
const names = new Set(["psgallery"]);
|
|
22
|
+
for (const [name, feed] of Object.entries(policy.repositories)) {
|
|
23
|
+
if (!powerShellRepositoryName.test(name) || names.has(name.toLowerCase())) {
|
|
24
|
+
throw new Error(`Duplicate or reserved PowerShell repository name: ${name}`);
|
|
25
|
+
}
|
|
26
|
+
if (!feed || typeof feed.uri !== "string")
|
|
27
|
+
throw new Error(`PowerShell repository "${name}" requires a URI`);
|
|
28
|
+
powerShellRepositoryUri(feed.uri);
|
|
29
|
+
names.add(name.toLowerCase());
|
|
30
|
+
}
|
|
31
|
+
if (!names.has(policy.default.toLowerCase())) {
|
|
32
|
+
throw new Error(`Default PowerShell repository "${policy.default}" is not declared`);
|
|
33
|
+
}
|
|
34
|
+
if (policy.allowed !== undefined &&
|
|
35
|
+
(!Array.isArray(policy.allowed) || policy.allowed.length === 0 ||
|
|
36
|
+
policy.allowed.some((name) => typeof name !== "string" || !names.has(name.toLowerCase())))) {
|
|
37
|
+
throw new Error("PowerShell allowed repositories must be a nonempty list of declared names or PSGallery");
|
|
38
|
+
}
|
|
39
|
+
if (policy.allowed && !policy.allowed.some((name) => name.toLowerCase() === policy.default.toLowerCase())) {
|
|
40
|
+
throw new Error("Default PowerShell repository must be allowed");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function powerShellRepositoryPolicyIdentity(policy) {
|
|
44
|
+
validatePowerShellRepositoryPolicy(policy);
|
|
45
|
+
return JSON.stringify({
|
|
46
|
+
repositories: Object.entries(policy.repositories)
|
|
47
|
+
.map(([name, feed]) => [name.toLowerCase(), powerShellRepositoryUri(feed.uri)])
|
|
48
|
+
.sort(([left], [right]) => left.localeCompare(right)),
|
|
49
|
+
default: policy.default.toLowerCase(),
|
|
50
|
+
allowed: policy.allowed ? [...new Set(policy.allowed.map((name) => name.toLowerCase()))].sort() : null,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function resolvePowerShellModule(win, module) {
|
|
54
|
+
const policy = win.powershell?.repositories;
|
|
55
|
+
if (policy)
|
|
56
|
+
validatePowerShellRepositoryPolicy(policy);
|
|
57
|
+
const requested = module.repository ?? policy?.default ?? "PSGallery";
|
|
58
|
+
if (policy?.allowed && !policy.allowed.some((name) => name.toLowerCase() === requested.toLowerCase())) {
|
|
59
|
+
throw new Error(`PowerShell module "${module.name}" requests disallowed repository "${requested}"`);
|
|
60
|
+
}
|
|
61
|
+
const entry = Object.entries(policy?.repositories ?? {}).find(([name]) => name.toLowerCase() === requested.toLowerCase());
|
|
62
|
+
return {
|
|
63
|
+
...module,
|
|
64
|
+
repository: entry?.[0] ?? requested,
|
|
65
|
+
...(entry ? { repositoryUri: powerShellRepositoryUri(entry[1].uri) } : {}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function validateWindowsPowerShellPolicy(win) {
|
|
69
|
+
if (win.powershell?.repositories)
|
|
70
|
+
validatePowerShellRepositoryPolicy(win.powershell.repositories);
|
|
71
|
+
for (const resource of win.dsc ?? []) {
|
|
72
|
+
if (resource.winix?.kind === "powershell-module")
|
|
73
|
+
resolvePowerShellModule(win, resource.winix.module);
|
|
74
|
+
if (resource.winix?.kind === "setting")
|
|
75
|
+
resolvePowerShellModule(win, { name: "Microsoft.Windows.Settings" });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ResourceHandle } from "../core/types.js";
|
|
2
|
-
import type { WinDscProperties, WinDscResource, WinPackageSource, WinSettings, WinFilePath, WinKnownFolder, WinKnownFolderName, WinStartupCommand, WinWslConfig, WinWslDistro, WinWslSetup } from "../types/index.js";
|
|
1
|
+
import type { Fragment, ResourceHandle } from "../core/types.js";
|
|
2
|
+
import type { WinDscProperties, WinDscResource, WinPackageSource, WinSettings, WinFilePath, WinKnownFolder, WinKnownFolderName, WinStartupCommand, WinWslConfig, WinWslDistro, WinWslSetup, WinPowerShellRepositoryPolicy } from "../types/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Accepted call shapes for `windows.package(...)`.
|
|
5
5
|
*
|
|
@@ -48,7 +48,7 @@ export interface WinSettingOpts {
|
|
|
48
48
|
dependsOn?: ResourceHandle | ResourceHandle[];
|
|
49
49
|
}
|
|
50
50
|
export interface WinPowerShellModuleOpts {
|
|
51
|
-
/** Registered
|
|
51
|
+
/** Registered repository; inherits the host policy, otherwise PSGallery. */
|
|
52
52
|
repository?: string;
|
|
53
53
|
dependsOn?: ResourceHandle | ResourceHandle[];
|
|
54
54
|
}
|
|
@@ -120,6 +120,8 @@ export interface WindowsHelper {
|
|
|
120
120
|
[Folder in WinKnownFolderName]: (path?: string) => WinKnownFolder;
|
|
121
121
|
};
|
|
122
122
|
powershell: {
|
|
123
|
+
/** Select and optionally restrict feeds for Winix-managed modules on this host. */
|
|
124
|
+
repositories(policy: WinPowerShellRepositoryPolicy): Fragment;
|
|
123
125
|
/** Install a current-user PowerShell 7 module using winix-windows.lock. */
|
|
124
126
|
module(name: string, opts?: WinPowerShellModuleOpts): ResourceHandle;
|
|
125
127
|
};
|
package/dist/helpers/windows.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { resolve, win32, posix } from "node:path";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { powerShellLiteral as psSingleQuoted } from "./utils.js";
|
|
9
|
+
import { validatePowerShellRepositoryPolicy } from "./windows-repositories.js";
|
|
9
10
|
const KNOWN_FOLDERS = {
|
|
10
11
|
documents: "MyDocuments",
|
|
11
12
|
desktop: "Desktop",
|
|
@@ -1009,6 +1010,10 @@ export const windows = {
|
|
|
1009
1010
|
userProfile: (path) => knownFolder("userProfile", path),
|
|
1010
1011
|
},
|
|
1011
1012
|
powershell: {
|
|
1013
|
+
repositories: (policy) => {
|
|
1014
|
+
validatePowerShellRepositoryPolicy(policy);
|
|
1015
|
+
return { windows: { powershell: { repositories: policy } } };
|
|
1016
|
+
},
|
|
1012
1017
|
module: (name, opts = {}) => {
|
|
1013
1018
|
if (typeof name !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(name)) {
|
|
1014
1019
|
throw new Error("windows.powershell.module requires a module name without wildcards or paths");
|
|
@@ -1016,8 +1021,8 @@ export const windows = {
|
|
|
1016
1021
|
if (!opts || typeof opts !== "object" || Array.isArray(opts)) {
|
|
1017
1022
|
throw new Error("windows.powershell.module options must be an object");
|
|
1018
1023
|
}
|
|
1019
|
-
const repository = opts.repository
|
|
1020
|
-
if (typeof repository !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(repository)) {
|
|
1024
|
+
const repository = opts.repository;
|
|
1025
|
+
if (repository !== undefined && (typeof repository !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(repository))) {
|
|
1021
1026
|
throw new Error("windows.powershell.module repository must be a registered repository name");
|
|
1022
1027
|
}
|
|
1023
1028
|
const resource = withDscMetadata(withDscToken({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { Fragment, ResourceHandle, FragmentFactory, PlatformFactory, ProfileFactory, LazyFragment, PlatformLazyFragment, FragmentEntry, FragmentResult, NixExpr, RawModuleRef, ImportRef, InputDef, InputWithOptions, WorkspaceDef, HostDef, EvalContext } from "./core/types.js";
|
|
2
|
-
export type { Attrs, BootOptions, DarwinNetworking, DarwinOptions, DarwinSecurity, DarwinDefaults, DarwinSystem, EnvironmentOptions, FirewallOptions, FontsOptions, FzfOptions, GitInclude, GitOptions, HomeActivation, HomebrewOptions, HomeConfig, HomeFile, HomeOptions, I18nOptions, LaunchdAgentOptions, LaunchdOptions, NeovimOptions, NetworkingOptions, NixConfig, NixGcOptions, NixHomebrewOptions, NixOptions, NixpkgsOptions, NixosSecurityOptions, NixosSystemOptions, NixPrimitive, NixSettings, NixValue, NixosOptions, OciContainerOptions, PackageRef, Script, ServicesOptions, StarshipOptions, SystemdOptions, SystemdService, SystemdTimer, TimeOptions, TmuxOptions, UserOptions, UsersOptions, VirtualisationOptions, WslOptions, XdgFile, XdgOptions, ZoxideOptions, ZshOptions, WindowsOptions, WinPackage, WinPackageSource, WinRawCommand, WinSettings, WinColorMode, WinStartFolder, WinTaskbarAlignment, WinTaskbarGroupingMode, WinTaskbarMultiMonMode, WinKnownFolder, WinKnownFolderName, WinFilePath, WinPowerShellModule, WinStartupCommand, WinStartupWindowStyle, } from "./types/index.js";
|
|
2
|
+
export type { Attrs, BootOptions, DarwinNetworking, DarwinOptions, DarwinSecurity, DarwinDefaults, DarwinSystem, EnvironmentOptions, FirewallOptions, FontsOptions, FzfOptions, GitInclude, GitOptions, HomeActivation, HomebrewOptions, HomeConfig, HomeFile, HomeOptions, I18nOptions, LaunchdAgentOptions, LaunchdOptions, NeovimOptions, NetworkingOptions, NixConfig, NixGcOptions, NixHomebrewOptions, NixOptions, NixpkgsOptions, NixosSecurityOptions, NixosSystemOptions, NixPrimitive, NixSettings, NixValue, NixosOptions, OciContainerOptions, PackageRef, Script, ServicesOptions, StarshipOptions, SystemdOptions, SystemdService, SystemdTimer, TimeOptions, TmuxOptions, UserOptions, UsersOptions, VirtualisationOptions, WslOptions, XdgFile, XdgOptions, ZoxideOptions, ZshOptions, WindowsOptions, WinPackage, WinPackageSource, WinRawCommand, WinSettings, WinColorMode, WinStartFolder, WinTaskbarAlignment, WinTaskbarGroupingMode, WinTaskbarMultiMonMode, WinKnownFolder, WinKnownFolderName, WinFilePath, WinPowerShellModule, WinPowerShellRepositoryPolicy, WinStartupCommand, WinStartupWindowStyle, } from "./types/index.js";
|
|
3
3
|
export { platform, feature, profile, host, workspace, input, defineInputs, rawModule, withContext } from "./sdk/index.js";
|
|
4
4
|
export type { WinixContext } from "./sdk/context.js";
|
|
5
5
|
export { evaluate } from "./evaluator/index.js";
|
package/dist/skill.js
CHANGED
|
@@ -285,7 +285,14 @@ Resources return handles that can be passed through \`dependsOn\`.
|
|
|
285
285
|
sources resolve relative to the directory containing winix.config.ts;
|
|
286
286
|
absolute paths, environment-variable paths, and file URLs are also supported.
|
|
287
287
|
- \`windows.powershell.module()\` declares a current-user PowerShell 7 module
|
|
288
|
-
by name, with optional repository (default PSGallery) and dependsOn.
|
|
288
|
+
by name, with optional repository (host default, otherwise PSGallery) and dependsOn.
|
|
289
|
+
windows.powershell.repositories({ repositories: { approved: { uri: "https://packages.example.com/powershell/v3/index.json" } }, default: "approved", allowed: ["approved"] })
|
|
290
|
+
declares a host-scoped feed policy. Compose it in work profiles; shared modules
|
|
291
|
+
and the automatic Settings installer inherit it after merging. Explicit
|
|
292
|
+
disallowed repositories fail without fallback. Named HTTPS feeds are registered
|
|
293
|
+
for the current user for resolution/activation, without changing global priority
|
|
294
|
+
or trust. Existing registrations with different URLs fail explicitly. Module
|
|
295
|
+
pins include source identity; personal hosts retain their own repositories.
|
|
289
296
|
Versions are recorded in the modules section of winix-windows.lock, not
|
|
290
297
|
handwritten declarations. PowerShell 7 with PSResourceGet is required for
|
|
291
298
|
resolution and installation.
|
package/dist/types/windows.d.ts
CHANGED
|
@@ -18,7 +18,17 @@ export interface WinStartupCommand {
|
|
|
18
18
|
}
|
|
19
19
|
export interface WinPowerShellModule {
|
|
20
20
|
name: string;
|
|
21
|
-
|
|
21
|
+
/** Omitted repositories inherit the host policy after all fragments merge. */
|
|
22
|
+
repository?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface WinPowerShellRepositoryPolicy {
|
|
25
|
+
/** Named HTTPS feeds to register for the current Windows user. No credentials in URLs. */
|
|
26
|
+
repositories: Record<string, {
|
|
27
|
+
uri: string;
|
|
28
|
+
}>;
|
|
29
|
+
default: string;
|
|
30
|
+
/** When specified, reject other repositories instead of falling back. */
|
|
31
|
+
allowed?: string[];
|
|
22
32
|
}
|
|
23
33
|
export interface WinWslDistro {
|
|
24
34
|
name: string;
|
|
@@ -258,6 +268,9 @@ export type WinDscProperties = {
|
|
|
258
268
|
* order controls apply order.
|
|
259
269
|
*/
|
|
260
270
|
export interface WindowsOptions extends Record<string, unknown> {
|
|
271
|
+
powershell?: {
|
|
272
|
+
repositories?: WinPowerShellRepositoryPolicy;
|
|
273
|
+
};
|
|
261
274
|
/** Declared packages, keyed by package id. */
|
|
262
275
|
packages?: Record<string, WinPackage>;
|
|
263
276
|
/** Raw commands to run on apply, in declaration order. */
|
package/package.json
CHANGED