@mnci/cli 4.11.0 → 4.12.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 +61 -0
- package/dist/cli.js +502 -117
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -38,7 +38,7 @@ module.exports = __toCommonJS(main_exports);
|
|
|
38
38
|
var import_commander = require("commander");
|
|
39
39
|
|
|
40
40
|
// src/project-scaffolding/add-project.use-case.ts
|
|
41
|
-
var
|
|
41
|
+
var import_node_path19 = require("path");
|
|
42
42
|
var import_prompts3 = require("@inquirer/prompts");
|
|
43
43
|
|
|
44
44
|
// src/nx-workspace/nx.client.ts
|
|
@@ -433,11 +433,12 @@ ${feedShortKey}:_password=\${PAT}
|
|
|
433
433
|
${feedShortKey}:email=npm-requires-this-and-never-uses-it
|
|
434
434
|
`;
|
|
435
435
|
}
|
|
436
|
+
var VSCODE_EXTENSION_TAG = "type:vscode-extension";
|
|
436
437
|
function releaseConfig(ci) {
|
|
437
438
|
const githubReleases = ci === "github";
|
|
438
439
|
return {
|
|
439
440
|
projectsRelationship: "independent",
|
|
440
|
-
projects: ["packages/*", "python-packages/*", "!tag:type:go-lib"],
|
|
441
|
+
projects: ["packages/*", "python-packages/*", `tag:${VSCODE_EXTENSION_TAG}`, "!tag:type:go-lib"],
|
|
441
442
|
releaseTag: { pattern: "{projectName}@{version}" },
|
|
442
443
|
git: { commit: false, tag: true, push: githubReleases },
|
|
443
444
|
version: {
|
|
@@ -449,7 +450,7 @@ function releaseConfig(ci) {
|
|
|
449
450
|
// Set here at `new` time it wins: the generator only fills this in when
|
|
450
451
|
// absent (it spreads the existing release.version over its default). Both
|
|
451
452
|
// globs are listed; `nx run-many` no-ops cleanly when one matches nothing.
|
|
452
|
-
preVersionCommand:
|
|
453
|
+
preVersionCommand: `npx nx run-many -t build --projects=packages/*,python-packages/*,tag:${VSCODE_EXTENSION_TAG}`,
|
|
453
454
|
// The lock file resync is OFF, and the reason is that it cannot succeed
|
|
454
455
|
// on the one release where it would matter.
|
|
455
456
|
//
|
|
@@ -476,7 +477,12 @@ function releaseConfig(ci) {
|
|
|
476
477
|
},
|
|
477
478
|
changelog: githubReleases ? {
|
|
478
479
|
workspaceChangelog: false,
|
|
479
|
-
projectChangelogs: { createRelease: "github", file: false }
|
|
480
|
+
projectChangelogs: { createRelease: "github", file: false },
|
|
481
|
+
// A GitHub Release needs a changelog, and a changelog needs a ref to start
|
|
482
|
+
// from. On the first release of a repository there is no tag to start from,
|
|
483
|
+
// and nx release dies after versioning (#243, measured). With this set it
|
|
484
|
+
// starts from the first commit; once a tag exists it is never consulted.
|
|
485
|
+
automaticFromRef: true
|
|
480
486
|
} : { workspaceChangelog: false }
|
|
481
487
|
};
|
|
482
488
|
}
|
|
@@ -1039,7 +1045,7 @@ function pypiReleasePreflight(registryKind) {
|
|
|
1039
1045
|
}
|
|
1040
1046
|
var SHALLOW_CLONE_GUARD = `node -e "const r=require('node:child_process').spawnSync('git',['rev-parse','--is-shallow-repository'],{encoding:'utf8'});if(r.status!==0){console.error('Could not determine whether this checkout has full history (git rev-parse --is-shallow-repository failed) - refusing to release. '+(r.stderr||'').trim());process.exit(1)}if(r.stdout.trim()==='true'){console.error('This checkout is a shallow clone. nx release resolves the current version of each package from its git tag, and silently falls back to the permanently-stale on-disk version when a tag cannot be found - which can propose, and publish, a version DOWNGRADE. Fetch full history before releasing - set fetchDepth (Azure) or fetch-depth (GitHub) to 0.');process.exit(1)}"`;
|
|
1041
1047
|
function releaseGuard(pythonPublishEnv, nugetPublishEnv) {
|
|
1042
|
-
return String.raw`node -e "const fs=require('node:fs'),cp=require('node:child_process');const npmCount=fs.globSync('packages/*/package.json').length;const csharpCount=fs.globSync('packages/*/*.csproj').length;const pythonCount=fs.globSync('python-packages/*/pyproject.toml').length;const dartCount=fs.globSync('packages/*/pubspec.yaml').length;const hasNpm=npmCount>0;const hasPython=pythonCount>0;const hasCsharp=csharpCount>0;const hasDart=dartCount>0;if(!hasNpm&&!hasPython&&!hasCsharp&&!hasDart){console.log('Nothing to release - skipping.');process.exit(0)}const specifier=process.env.RELEASE_SPECIFIER||'';let releaseCmd='npx nx release --yes';if(specifier){if(!/^(major|minor|patch|\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?)$/.test(specifier)){console.error('RELEASE_SPECIFIER value \''+specifier+'\' is invalid - use major, minor, patch, or an exact version like 1.2.3.');process.exit(1)}const releaseProjectCount=npmCount+csharpCount+pythonCount+dartCount;if(/^(major|minor|patch)$/.test(specifier)&&releaseProjectCount>1){console.error('RELEASE_SPECIFIER is a keyword (\''+specifier+'\') but this workspace has '+releaseProjectCount+' releasable packages - a keyword under-bumps interdependent packages, because nx computes the dependency-bump pass from a stale cached version. Set RELEASE_SPECIFIER to an exact version instead, or clear it.');process.exit(1)}releaseCmd='npx nx release '+specifier+' --yes'}const env={...process.env};${pythonPublishEnv}${nugetPublishEnv}process.exit(cp.spawnSync(releaseCmd,{stdio:'inherit',shell:true,env}).status ?? 1)"`;
|
|
1048
|
+
return String.raw`node -e "const fs=require('node:fs'),cp=require('node:child_process');const npmCount=fs.globSync('packages/*/package.json').length;const csharpCount=fs.globSync('packages/*/*.csproj').length;const pythonCount=fs.globSync('python-packages/*/pyproject.toml').length;const dartCount=fs.globSync('packages/*/pubspec.yaml').length;const vscodeCount=fs.globSync('apps/*/package.json').filter(p=>{try{return(JSON.parse(fs.readFileSync(p,'utf8')).nx?.tags||[]).includes('${VSCODE_EXTENSION_TAG}')}catch{return false}}).length;const hasNpm=npmCount>0;const hasPython=pythonCount>0;const hasCsharp=csharpCount>0;const hasDart=dartCount>0;const hasVscode=vscodeCount>0;if(!hasNpm&&!hasPython&&!hasCsharp&&!hasDart&&!hasVscode){console.log('Nothing to release - skipping.');process.exit(0)}const specifier=process.env.RELEASE_SPECIFIER||'';let releaseCmd='npx nx release --yes';if(specifier){if(!/^(major|minor|patch|\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?)$/.test(specifier)){console.error('RELEASE_SPECIFIER value \''+specifier+'\' is invalid - use major, minor, patch, or an exact version like 1.2.3.');process.exit(1)}const releaseProjectCount=npmCount+csharpCount+pythonCount+dartCount+vscodeCount;if(/^(major|minor|patch)$/.test(specifier)&&releaseProjectCount>1){console.error('RELEASE_SPECIFIER is a keyword (\''+specifier+'\') but this workspace has '+releaseProjectCount+' releasable packages - a keyword under-bumps interdependent packages, because nx computes the dependency-bump pass from a stale cached version. Set RELEASE_SPECIFIER to an exact version instead, or clear it.');process.exit(1)}releaseCmd='npx nx release '+specifier+' --yes'}const env={...process.env};${pythonPublishEnv}${nugetPublishEnv}process.exit(cp.spawnSync(releaseCmd,{stdio:'inherit',shell:true,env}).status ?? 1)"`;
|
|
1043
1049
|
}
|
|
1044
1050
|
var PYPI_TOKEN_VARIABLE = "PYPI_TOKEN";
|
|
1045
1051
|
var AZURE_PAT_VARIABLE = "PAT";
|
|
@@ -1370,11 +1376,14 @@ ${npmAuthPreflight(registryKind) ? `
|
|
|
1370
1376
|
# the run rather than under-bumping silently: clear the variable back to
|
|
1371
1377
|
# '' once the override is no longer needed.
|
|
1372
1378
|
- script: ${releaseGuard(pythonPublishEnvFragment(pythonPublishUrl2, registryKind), nugetPublishEnvFragment(nugetFeedUrl2))}
|
|
1373
|
-
displayName: Release \u2014 version, tag and publish (npm + Python + C#)
|
|
1379
|
+
displayName: Release \u2014 version, tag and publish (npm + Python + C# + VS Code)
|
|
1374
1380
|
condition: ${onMain}
|
|
1375
1381
|
env:
|
|
1376
1382
|
${npmAuthName}: ${npmAuthValue}${pypiTokenEnvLine(registryKind, (name) => `$(${name})`, " ".repeat(6))}
|
|
1377
1383
|
RELEASE_SPECIFIER: $(RELEASE_SPECIFIER)
|
|
1384
|
+
# A VS Code extension publishes with it; tools/vscode-extension.cjs skips the
|
|
1385
|
+
# Marketplace when it is unset, including when Azure leaves it as '$(VSCE_PAT)'.
|
|
1386
|
+
VSCE_PAT: $(VSCE_PAT)
|
|
1378
1387
|
|
|
1379
1388
|
# nx release's own git push (release.git.push) is deliberately left off: it
|
|
1380
1389
|
# only runs when a remote GitHub/GitLab Release is configured, which this
|
|
@@ -1626,11 +1635,14 @@ ${npmAuthPreflight(registryKind) ? `
|
|
|
1626
1635
|
# releaseConfig's remarks for why that is safe on this Nx version and
|
|
1627
1636
|
# why every other provider combination keeps the explicit push step below.` : ""}
|
|
1628
1637
|
- run: ${releaseGuard(pythonPublishEnvFragment(pythonPublishUrl2, registryKind), nugetPublishEnvFragment(nugetFeedUrl2))}
|
|
1629
|
-
name: Release \u2014 version, tag${githubReleases ? ", publish and GitHub Release" : " and publish"} (npm + Python + C#)
|
|
1638
|
+
name: Release \u2014 version, tag${githubReleases ? ", publish and GitHub Release" : " and publish"} (npm + Python + C# + VS Code)
|
|
1630
1639
|
if: \${{ ${onMain} }}
|
|
1631
1640
|
env:
|
|
1632
1641
|
${npmAuthName}: ${npmAuthValue}${pypiTokenEnvLine(registryKind, (name) => `\${{ secrets.${name} }}`, " ".repeat(10))}
|
|
1633
|
-
RELEASE_SPECIFIER: \${{ vars.RELEASE_SPECIFIER }}
|
|
1642
|
+
RELEASE_SPECIFIER: \${{ vars.RELEASE_SPECIFIER }}
|
|
1643
|
+
# A VS Code extension publishes with it; tools/vscode-extension.cjs
|
|
1644
|
+
# skips the Marketplace when it is unset.
|
|
1645
|
+
VSCE_PAT: \${{ secrets.VSCE_PAT }}${githubReleases ? `
|
|
1634
1646
|
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}` : ""}
|
|
1635
1647
|
${githubReleases ? "" : `
|
|
1636
1648
|
# nx release's own git push (release.git.push) is deliberately left off: it
|
|
@@ -3789,12 +3801,366 @@ function addReactInternalLib(workspaceRoot, name, stack) {
|
|
|
3789
3801
|
);
|
|
3790
3802
|
}
|
|
3791
3803
|
|
|
3804
|
+
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
3805
|
+
var import_node_fs11 = require("fs");
|
|
3806
|
+
var import_node_path15 = require("path");
|
|
3807
|
+
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
3808
|
+
var VSCODE_SIDECAR_TARGETS = {
|
|
3809
|
+
"win32-x64": "windows-amd64",
|
|
3810
|
+
"win32-arm64": "windows-arm64",
|
|
3811
|
+
"linux-x64": "linux-amd64",
|
|
3812
|
+
"linux-arm64": "linux-arm64",
|
|
3813
|
+
"alpine-x64": "linux-amd64",
|
|
3814
|
+
"alpine-arm64": "linux-arm64",
|
|
3815
|
+
"darwin-x64": "darwin-amd64",
|
|
3816
|
+
"darwin-arm64": "darwin-arm64"
|
|
3817
|
+
};
|
|
3818
|
+
var VSCODE_EXTENSION_SCRIPT = String.raw`#!/usr/bin/env node
|
|
3819
|
+
// Written by mnci: 'mnci add vscode-extension' creates it and 'mnci upgrade'
|
|
3820
|
+
// rewrites it, so local edits do not survive an upgrade.
|
|
3821
|
+
//
|
|
3822
|
+
// Packages and publishes a VS Code extension project. Its Nx targets call it:
|
|
3823
|
+
// node tools/vscode-extension.cjs package apps/<name> [--sidecar <go-app>]
|
|
3824
|
+
// node tools/vscode-extension.cjs publish apps/<name> [--sidecar <go-app>]
|
|
3825
|
+
// Without --sidecar: one universal dist/drop/<name>.vsix.
|
|
3826
|
+
// With --sidecar: one dist/drop/<name>-<target>.vsix per Marketplace target, each
|
|
3827
|
+
// carrying that platform's binary from the Go app's build-all in bin/.
|
|
3828
|
+
'use strict'
|
|
3829
|
+
const { spawnSync } = require('node:child_process')
|
|
3830
|
+
const { cpSync, existsSync, mkdirSync, readFileSync, rmSync } = require('node:fs')
|
|
3831
|
+
const { dirname, join, resolve } = require('node:path')
|
|
3832
|
+
|
|
3833
|
+
const TARGETS = ${JSON.stringify(VSCODE_SIDECAR_TARGETS)}
|
|
3834
|
+
const DROP = resolve('dist/drop')
|
|
3835
|
+
const VSCE_FLAGS = ['--no-dependencies', '--skip-license', '--allow-missing-repository']
|
|
3836
|
+
|
|
3837
|
+
function fail (message) {
|
|
3838
|
+
console.error(message)
|
|
3839
|
+
process.exit(1)
|
|
3840
|
+
}
|
|
3841
|
+
|
|
3842
|
+
function bin (packageName, command) {
|
|
3843
|
+
const manifestPath = require.resolve(packageName + '/package.json', { paths: [process.cwd()] })
|
|
3844
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
|
|
3845
|
+
const entry = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin[command]
|
|
3846
|
+
|
|
3847
|
+
return join(dirname(manifestPath), entry)
|
|
3848
|
+
}
|
|
3849
|
+
|
|
3850
|
+
function run (packageName, command, args, options) {
|
|
3851
|
+
const result = spawnSync(process.execPath, [bin(packageName, command), ...args], { stdio: 'inherit', ...options })
|
|
3852
|
+
if (result.status !== 0) process.exit(result.status ?? 1)
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
function vsixFiles (name, sidecar) {
|
|
3856
|
+
return sidecar
|
|
3857
|
+
? Object.keys(TARGETS).map(target => join(DROP, name + '-' + target + '.vsix'))
|
|
3858
|
+
: [join(DROP, name + '.vsix')]
|
|
3859
|
+
}
|
|
3860
|
+
|
|
3861
|
+
function packageExtension (projectRoot, manifest, sidecar) {
|
|
3862
|
+
mkdirSync(DROP, { recursive: true })
|
|
3863
|
+
if (!sidecar) {
|
|
3864
|
+
run('@vscode/vsce', 'vsce', ['package', ...VSCE_FLAGS, '--out', vsixFiles(manifest.name)[0]], { cwd: projectRoot })
|
|
3865
|
+
|
|
3866
|
+
return
|
|
3867
|
+
}
|
|
3868
|
+
run('nx', 'nx', ['run', sidecar + ':build-all'], { env: { ...process.env, VERSION: manifest.version } })
|
|
3869
|
+
const staging = join(projectRoot, 'bin')
|
|
3870
|
+
try {
|
|
3871
|
+
for (const [target, platform] of Object.entries(TARGETS)) {
|
|
3872
|
+
const source = join('dist/platforms', sidecar, platform)
|
|
3873
|
+
if (!existsSync(source)) fail('No ' + platform + ' build of ' + sidecar + ' at ' + source + ' - its build-all target did not write one.')
|
|
3874
|
+
rmSync(staging, { recursive: true, force: true })
|
|
3875
|
+
cpSync(source, staging, { recursive: true })
|
|
3876
|
+
run('@vscode/vsce', 'vsce', ['package', '--target', target, ...VSCE_FLAGS, '--out', join(DROP, manifest.name + '-' + target + '.vsix')], { cwd: projectRoot })
|
|
3877
|
+
}
|
|
3878
|
+
} finally {
|
|
3879
|
+
rmSync(staging, { recursive: true, force: true })
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3883
|
+
function publishExtension (manifest, sidecar, dryRun) {
|
|
3884
|
+
if (dryRun) {
|
|
3885
|
+
console.log('Dry run - would publish ' + vsixFiles(manifest.name, sidecar).join(', ') + ' to the Marketplace.')
|
|
3886
|
+
|
|
3887
|
+
return
|
|
3888
|
+
}
|
|
3889
|
+
const token = process.env.VSCE_PAT ?? ''
|
|
3890
|
+
if (token === '' || /^\$\(.*\)$/.test(token)) {
|
|
3891
|
+
console.log('VSCE_PAT is not set - skipping the Marketplace publish of ' + manifest.name + '. Add it as a CI secret to publish.')
|
|
3892
|
+
|
|
3893
|
+
return
|
|
3894
|
+
}
|
|
3895
|
+
const files = vsixFiles(manifest.name, sidecar)
|
|
3896
|
+
const missing = files.filter(file => !existsSync(file))
|
|
3897
|
+
if (missing.length > 0) fail('Nothing to publish: ' + missing.join(', ') + ' not found - run the package target first.')
|
|
3898
|
+
run('@vscode/vsce', 'vsce', ['publish', '--packagePath', ...files, '--skip-duplicate'])
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
const [command, projectRoot, ...rest] = process.argv.slice(2)
|
|
3902
|
+
const sidecarIndex = rest.indexOf('--sidecar')
|
|
3903
|
+
const sidecar = sidecarIndex === -1 ? undefined : rest[sidecarIndex + 1]
|
|
3904
|
+
if (!projectRoot || !existsSync(join(projectRoot, 'package.json'))) fail('Usage: node tools/vscode-extension.cjs package|publish <project root> [--sidecar <go-app>]')
|
|
3905
|
+
const manifest = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8'))
|
|
3906
|
+
// nx release --dry-run hands the publish target --dryRun=true and sets NX_DRY_RUN
|
|
3907
|
+
// (measured on Nx 23), so a dry run never reaches the Marketplace, token or not.
|
|
3908
|
+
const dryRun = rest.some(argument => /^--dry-?run(=true)?$/i.test(argument)) || process.env.NX_DRY_RUN === 'true'
|
|
3909
|
+
if (command === 'package') packageExtension(projectRoot, manifest, sidecar)
|
|
3910
|
+
else if (command === 'publish') publishExtension(manifest, sidecar, dryRun)
|
|
3911
|
+
else fail('Unknown command ' + command + ' - expected package or publish.')
|
|
3912
|
+
`;
|
|
3913
|
+
var VSCODE_IGNORE = `src/**
|
|
3914
|
+
test/**
|
|
3915
|
+
out-tsc/**
|
|
3916
|
+
test-output/**
|
|
3917
|
+
**/*.map
|
|
3918
|
+
**/*.d.ts
|
|
3919
|
+
**/*.spec.*
|
|
3920
|
+
tsconfig*.json
|
|
3921
|
+
jest.config.*
|
|
3922
|
+
vitest.config.*
|
|
3923
|
+
.spec.swcrc
|
|
3924
|
+
node_modules/**
|
|
3925
|
+
`;
|
|
3926
|
+
function vscodeExtensionMain(name) {
|
|
3927
|
+
return `import * as vscode from 'vscode'
|
|
3928
|
+
|
|
3929
|
+
export function activate (context: vscode.ExtensionContext): void {
|
|
3930
|
+
context.subscriptions.push(
|
|
3931
|
+
vscode.commands.registerCommand('${name}.hello', () => {
|
|
3932
|
+
void vscode.window.showInformationMessage('Hello from ${name}')
|
|
3933
|
+
}),
|
|
3934
|
+
)
|
|
3935
|
+
}
|
|
3936
|
+
|
|
3937
|
+
export function deactivate (): void {}
|
|
3938
|
+
`;
|
|
3939
|
+
}
|
|
3940
|
+
function vscodeExtensionMainSpec(name) {
|
|
3941
|
+
return `import * as vscode from 'vscode'
|
|
3942
|
+
import { activate } from './main'
|
|
3943
|
+
|
|
3944
|
+
describe('activate', () => {
|
|
3945
|
+
it('registers the ${name}.hello command', async () => {
|
|
3946
|
+
const context = { subscriptions: [] } as unknown as vscode.ExtensionContext
|
|
3947
|
+
|
|
3948
|
+
activate(context)
|
|
3949
|
+
|
|
3950
|
+
expect(context.subscriptions).toHaveLength(1)
|
|
3951
|
+
expect(await vscode.commands.getCommands()).toContain('${name}.hello')
|
|
3952
|
+
})
|
|
3953
|
+
})
|
|
3954
|
+
`;
|
|
3955
|
+
}
|
|
3956
|
+
var VSCODE_STUB = `// Stands in for the 'vscode' module in unit tests: that module exists only
|
|
3957
|
+
// inside the extension host. Extend it as the extension reaches for more API.
|
|
3958
|
+
const registered = new Map<string, (...arguments_: unknown[]) => unknown>()
|
|
3959
|
+
|
|
3960
|
+
export const commands = {
|
|
3961
|
+
registerCommand (id: string, handler: (...arguments_: unknown[]) => unknown): { dispose: () => void } {
|
|
3962
|
+
registered.set(id, handler)
|
|
3963
|
+
|
|
3964
|
+
return { dispose: () => { registered.delete(id) } }
|
|
3965
|
+
},
|
|
3966
|
+
getCommands (): Promise<string[]> {
|
|
3967
|
+
return Promise.resolve(registered.keys().toArray())
|
|
3968
|
+
},
|
|
3969
|
+
executeCommand (id: string, ...arguments_: unknown[]): Promise<unknown> {
|
|
3970
|
+
return Promise.resolve(registered.get(id)?.(...arguments_))
|
|
3971
|
+
},
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
export const window = {
|
|
3975
|
+
showInformationMessage (_message: string): Promise<undefined> {
|
|
3976
|
+
return Promise.resolve(undefined)
|
|
3977
|
+
},
|
|
3978
|
+
}
|
|
3979
|
+
`;
|
|
3980
|
+
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
3981
|
+
function mapVscodeToStub(projectRoot, testRunner) {
|
|
3982
|
+
const [file, anchor, mapping] = testRunner === "jest" ? ["jest.config.cts", "testEnvironment: 'node',", `moduleNameMapper: { '^vscode$': '<rootDir>/${VSCODE_STUB_PATH}' },`] : ["vitest.config.mts", "environment: 'node',", `alias: { vscode: \`\${import.meta.dirname}/${VSCODE_STUB_PATH}\` },`];
|
|
3983
|
+
const path = (0, import_node_path15.join)(projectRoot, file);
|
|
3984
|
+
const content = fileExists(path) ? (0, import_node_fs11.readFileSync)(path, "utf8") : "";
|
|
3985
|
+
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
3986
|
+
if (line === void 0) {
|
|
3987
|
+
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
3988
|
+
}
|
|
3989
|
+
const indent = line.slice(0, line.indexOf(anchor));
|
|
3990
|
+
writeFileEnsured(path, content.replace(line, () => `${line}
|
|
3991
|
+
${indent}${mapping}`));
|
|
3992
|
+
}
|
|
3993
|
+
function ensureVscodeToolchain(workspaceRoot) {
|
|
3994
|
+
const missing = ["@types/vscode", "@vscode/vsce"].filter((name) => !hasPlugin(workspaceRoot, name));
|
|
3995
|
+
if (missing.length === 0) {
|
|
3996
|
+
return;
|
|
3997
|
+
}
|
|
3998
|
+
logger.step(`Installing the VS Code extension toolchain (${missing.join(", ")})`);
|
|
3999
|
+
if (runShell("npm", ["install", "--save-dev", ...missing, "--no-audit", "--no-fund"], workspaceRoot) !== 0) {
|
|
4000
|
+
throw new Error(`npm install of ${missing.join(", ")} failed`);
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
function defaultPublisher(workspaceRoot) {
|
|
4004
|
+
const { name } = readJson((0, import_node_path15.join)(workspaceRoot, "package.json"));
|
|
4005
|
+
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
4006
|
+
}
|
|
4007
|
+
function reshapeManifest(projectRoot, name, publisher, typesVersion) {
|
|
4008
|
+
const manifestPath = (0, import_node_path15.join)(projectRoot, "package.json");
|
|
4009
|
+
const manifest = readJson(manifestPath);
|
|
4010
|
+
const { nx = {}, ...rest } = manifest;
|
|
4011
|
+
const targets = { ...nx.targets };
|
|
4012
|
+
for (const target of ["serve", "prune", "prune-lockfile", "copy-workspace-modules"]) {
|
|
4013
|
+
delete targets[target];
|
|
4014
|
+
}
|
|
4015
|
+
const build = targets.build ?? {};
|
|
4016
|
+
targets.build = {
|
|
4017
|
+
...build,
|
|
4018
|
+
options: {
|
|
4019
|
+
...build.options,
|
|
4020
|
+
bundle: true,
|
|
4021
|
+
thirdParty: true,
|
|
4022
|
+
external: ["vscode"],
|
|
4023
|
+
generatePackageJson: false
|
|
4024
|
+
}
|
|
4025
|
+
};
|
|
4026
|
+
writeFileEnsured(
|
|
4027
|
+
manifestPath,
|
|
4028
|
+
toJson({
|
|
4029
|
+
...rest,
|
|
4030
|
+
name,
|
|
4031
|
+
displayName: name,
|
|
4032
|
+
version: rest.version ?? "0.0.1",
|
|
4033
|
+
publisher,
|
|
4034
|
+
engines: { vscode: `^${typesVersion}` },
|
|
4035
|
+
categories: ["Other"],
|
|
4036
|
+
main: "./dist/main.js",
|
|
4037
|
+
activationEvents: [],
|
|
4038
|
+
contributes: { commands: [{ command: `${name}.hello`, title: `${name}: Hello` }] },
|
|
4039
|
+
nx: { ...nx, tags: [.../* @__PURE__ */ new Set([...nx.tags ?? [], VSCODE_EXTENSION_TAG])], targets }
|
|
4040
|
+
})
|
|
4041
|
+
);
|
|
4042
|
+
}
|
|
4043
|
+
function addVscodeTypes(tsconfigPath) {
|
|
4044
|
+
if (!fileExists(tsconfigPath)) {
|
|
4045
|
+
return;
|
|
4046
|
+
}
|
|
4047
|
+
const tsconfig = readJson(tsconfigPath);
|
|
4048
|
+
const compilerOptions = tsconfig.compilerOptions ?? {};
|
|
4049
|
+
const types = compilerOptions.types ?? [];
|
|
4050
|
+
if (types.includes("vscode")) {
|
|
4051
|
+
return;
|
|
4052
|
+
}
|
|
4053
|
+
writeFileEnsured(tsconfigPath, toJson({ ...tsconfig, compilerOptions: { ...compilerOptions, types: [...types, "vscode"] } }));
|
|
4054
|
+
}
|
|
4055
|
+
function vscodeExtensionPackageTarget(name, sidecar) {
|
|
4056
|
+
const outputs = sidecar ? Object.keys(VSCODE_SIDECAR_TARGETS).map((target) => `{workspaceRoot}/dist/drop/${name}-${target}.vsix`) : [`{workspaceRoot}/dist/drop/${name}.vsix`];
|
|
4057
|
+
return {
|
|
4058
|
+
executor: "nx:run-commands",
|
|
4059
|
+
dependsOn: ["build"],
|
|
4060
|
+
outputs,
|
|
4061
|
+
options: { command: `node ${VSCODE_EXTENSION_SCRIPT_PATH} package apps/${name}${sidecar ? ` --sidecar ${sidecar}` : ""}` }
|
|
4062
|
+
};
|
|
4063
|
+
}
|
|
4064
|
+
function vscodeExtensionPublishTarget(name, sidecar) {
|
|
4065
|
+
return {
|
|
4066
|
+
executor: "nx:run-commands",
|
|
4067
|
+
dependsOn: ["package"],
|
|
4068
|
+
options: { command: `node ${VSCODE_EXTENSION_SCRIPT_PATH} publish apps/${name}${sidecar ? ` --sidecar ${sidecar}` : ""}` }
|
|
4069
|
+
};
|
|
4070
|
+
}
|
|
4071
|
+
function addDebugLaunch(workspaceRoot, name) {
|
|
4072
|
+
const file = (0, import_node_fs11.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
4073
|
+
if (file === void 0) {
|
|
4074
|
+
return;
|
|
4075
|
+
}
|
|
4076
|
+
const path = (0, import_node_path15.join)(workspaceRoot, file);
|
|
4077
|
+
const workspace = readCodeWorkspace(path) ?? {};
|
|
4078
|
+
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
4079
|
+
const taskLabel = `${name}: build (development)`;
|
|
4080
|
+
const launchName = `${name}: debug`;
|
|
4081
|
+
const tasks = (workspace.tasks?.tasks ?? []).filter((task) => task.label !== taskLabel);
|
|
4082
|
+
const configurations = (workspace.launch?.configurations ?? []).filter((configuration) => configuration.name !== launchName);
|
|
4083
|
+
writeFileEnsured(
|
|
4084
|
+
path,
|
|
4085
|
+
toJson({
|
|
4086
|
+
...workspace,
|
|
4087
|
+
tasks: {
|
|
4088
|
+
version: workspace.tasks?.version ?? "2.0.0",
|
|
4089
|
+
tasks: [...tasks, { label: taskLabel, type: "shell", command: `npx nx run ${name}:build:development`, problemMatcher: [] }]
|
|
4090
|
+
},
|
|
4091
|
+
launch: {
|
|
4092
|
+
version: workspace.launch?.version ?? "0.2.0",
|
|
4093
|
+
configurations: [
|
|
4094
|
+
...configurations,
|
|
4095
|
+
{
|
|
4096
|
+
name: launchName,
|
|
4097
|
+
type: "extensionHost",
|
|
4098
|
+
request: "launch",
|
|
4099
|
+
args: [`--extensionDevelopmentPath=${folder}/apps/${name}`],
|
|
4100
|
+
outFiles: [`${folder}/apps/${name}/dist/**/*.js`],
|
|
4101
|
+
preLaunchTask: taskLabel
|
|
4102
|
+
}
|
|
4103
|
+
]
|
|
4104
|
+
}
|
|
4105
|
+
})
|
|
4106
|
+
);
|
|
4107
|
+
}
|
|
4108
|
+
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
4109
|
+
const apps = (0, import_node_path15.join)(workspaceRoot, "apps");
|
|
4110
|
+
let entries;
|
|
4111
|
+
try {
|
|
4112
|
+
entries = (0, import_node_fs11.readdirSync)(apps);
|
|
4113
|
+
} catch {
|
|
4114
|
+
return false;
|
|
4115
|
+
}
|
|
4116
|
+
const hasExtension = entries.some((entry) => {
|
|
4117
|
+
const manifestPath = (0, import_node_path15.join)(apps, entry, "package.json");
|
|
4118
|
+
if (!fileExists(manifestPath)) {
|
|
4119
|
+
return false;
|
|
4120
|
+
}
|
|
4121
|
+
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
4122
|
+
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
4123
|
+
});
|
|
4124
|
+
const path = (0, import_node_path15.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
4125
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs11.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
4126
|
+
return false;
|
|
4127
|
+
}
|
|
4128
|
+
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
4129
|
+
return true;
|
|
4130
|
+
}
|
|
4131
|
+
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
4132
|
+
const { sidecar } = options;
|
|
4133
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path15.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
4134
|
+
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
4135
|
+
}
|
|
4136
|
+
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4137
|
+
ensureVscodeToolchain(workspaceRoot);
|
|
4138
|
+
const projectRoot = (0, import_node_path15.join)(workspaceRoot, "apps", name);
|
|
4139
|
+
const typesVersion = readJson((0, import_node_path15.join)(workspaceRoot, "node_modules/@types/vscode/package.json")).version;
|
|
4140
|
+
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot), typesVersion);
|
|
4141
|
+
addVscodeTypes((0, import_node_path15.join)(projectRoot, "tsconfig.app.json"));
|
|
4142
|
+
addVscodeTypes((0, import_node_path15.join)(projectRoot, "tsconfig.spec.json"));
|
|
4143
|
+
writeFileEnsured((0, import_node_path15.join)(projectRoot, "src/main.ts"), vscodeExtensionMain(name));
|
|
4144
|
+
writeFileEnsured((0, import_node_path15.join)(projectRoot, "src/main.spec.ts"), vscodeExtensionMainSpec(name));
|
|
4145
|
+
writeFileEnsured((0, import_node_path15.join)(projectRoot, VSCODE_STUB_PATH), VSCODE_STUB);
|
|
4146
|
+
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
4147
|
+
writeFileEnsured((0, import_node_path15.join)(projectRoot, ".vscodeignore"), VSCODE_IGNORE);
|
|
4148
|
+
writeFileEnsured((0, import_node_path15.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH), VSCODE_EXTENSION_SCRIPT);
|
|
4149
|
+
addNxTargets((0, import_node_path15.join)(projectRoot, "package.json"), {
|
|
4150
|
+
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
4151
|
+
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
4152
|
+
});
|
|
4153
|
+
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
4154
|
+
registerProjectCommands(workspaceRoot, name, { build: true });
|
|
4155
|
+
addDebugLaunch(workspaceRoot, name);
|
|
4156
|
+
}
|
|
4157
|
+
|
|
3792
4158
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
3793
|
-
var
|
|
4159
|
+
var import_node_path17 = require("path");
|
|
3794
4160
|
|
|
3795
4161
|
// src/dependency-management/manifest.repository.ts
|
|
3796
|
-
var
|
|
3797
|
-
var
|
|
4162
|
+
var import_node_fs12 = require("fs");
|
|
4163
|
+
var import_node_path16 = require("path");
|
|
3798
4164
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
3799
4165
|
var ROOT_LABEL = "(root)";
|
|
3800
4166
|
var MANIFEST_GLOBS = {
|
|
@@ -3827,23 +4193,23 @@ function projectOf(manifestRelativePath) {
|
|
|
3827
4193
|
}
|
|
3828
4194
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
3829
4195
|
if (ecosystem === "go") {
|
|
3830
|
-
return fileExists((0,
|
|
4196
|
+
return fileExists((0, import_node_path16.join)(workspaceRoot, "go.mod"));
|
|
3831
4197
|
}
|
|
3832
4198
|
if (ecosystem === "nuget") {
|
|
3833
|
-
return (0,
|
|
4199
|
+
return (0, import_node_fs12.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
3834
4200
|
}
|
|
3835
4201
|
const rootMarker = {
|
|
3836
4202
|
npm: "package.json",
|
|
3837
4203
|
pip: "requirements-dev.txt",
|
|
3838
4204
|
pub: "pubspec.yaml"
|
|
3839
4205
|
};
|
|
3840
|
-
return fileExists((0,
|
|
4206
|
+
return fileExists((0, import_node_path16.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs12.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
3841
4207
|
}
|
|
3842
4208
|
function collectNpm(workspaceRoot) {
|
|
3843
4209
|
const sites = [];
|
|
3844
|
-
const relativePaths = ["package.json", ...(0,
|
|
4210
|
+
const relativePaths = ["package.json", ...(0, import_node_fs12.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
3845
4211
|
for (const relativePath of relativePaths) {
|
|
3846
|
-
const manifestPath = (0,
|
|
4212
|
+
const manifestPath = (0, import_node_path16.join)(workspaceRoot, relativePath);
|
|
3847
4213
|
try {
|
|
3848
4214
|
const manifest = readJson(manifestPath);
|
|
3849
4215
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -3904,17 +4270,17 @@ function collectPip(workspaceRoot) {
|
|
|
3904
4270
|
name: parsed.name,
|
|
3905
4271
|
ecosystem: "pip",
|
|
3906
4272
|
project: projectOf(relativePath),
|
|
3907
|
-
manifestPath: (0,
|
|
4273
|
+
manifestPath: (0, import_node_path16.join)(workspaceRoot, relativePath),
|
|
3908
4274
|
section,
|
|
3909
4275
|
spec: parsed.spec,
|
|
3910
4276
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
3911
4277
|
});
|
|
3912
4278
|
};
|
|
3913
|
-
const pyprojectPaths = (0,
|
|
4279
|
+
const pyprojectPaths = (0, import_node_fs12.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
3914
4280
|
for (const relativePath of pyprojectPaths) {
|
|
3915
4281
|
let content;
|
|
3916
4282
|
try {
|
|
3917
|
-
content = (0,
|
|
4283
|
+
content = (0, import_node_fs12.readFileSync)((0, import_node_path16.join)(workspaceRoot, relativePath), "utf8");
|
|
3918
4284
|
} catch {
|
|
3919
4285
|
continue;
|
|
3920
4286
|
}
|
|
@@ -3925,14 +4291,14 @@ function collectPip(workspaceRoot) {
|
|
|
3925
4291
|
}
|
|
3926
4292
|
const requirementsPaths = [
|
|
3927
4293
|
"requirements-dev.txt",
|
|
3928
|
-
...(0,
|
|
4294
|
+
...(0, import_node_fs12.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
3929
4295
|
];
|
|
3930
4296
|
for (const relativePath of requirementsPaths) {
|
|
3931
|
-
if (!fileExists((0,
|
|
4297
|
+
if (!fileExists((0, import_node_path16.join)(workspaceRoot, relativePath))) {
|
|
3932
4298
|
continue;
|
|
3933
4299
|
}
|
|
3934
4300
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
3935
|
-
const lines = (0,
|
|
4301
|
+
const lines = (0, import_node_fs12.readFileSync)((0, import_node_path16.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
3936
4302
|
for (const line of lines) {
|
|
3937
4303
|
push(relativePath, section, line);
|
|
3938
4304
|
}
|
|
@@ -3970,11 +4336,11 @@ function pyprojectDependencies(content) {
|
|
|
3970
4336
|
}
|
|
3971
4337
|
function collectPub(workspaceRoot) {
|
|
3972
4338
|
const sites = [];
|
|
3973
|
-
const pubspecPaths = (0,
|
|
4339
|
+
const pubspecPaths = (0, import_node_fs12.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
3974
4340
|
for (const relativePath of pubspecPaths) {
|
|
3975
4341
|
let content;
|
|
3976
4342
|
try {
|
|
3977
|
-
content = (0,
|
|
4343
|
+
content = (0, import_node_fs12.readFileSync)((0, import_node_path16.join)(workspaceRoot, relativePath), "utf8");
|
|
3978
4344
|
} catch {
|
|
3979
4345
|
continue;
|
|
3980
4346
|
}
|
|
@@ -3984,7 +4350,7 @@ function collectPub(workspaceRoot) {
|
|
|
3984
4350
|
name: entry.name,
|
|
3985
4351
|
ecosystem: "pub",
|
|
3986
4352
|
project: projectOf(relativePath),
|
|
3987
|
-
manifestPath: (0,
|
|
4353
|
+
manifestPath: (0, import_node_path16.join)(workspaceRoot, relativePath),
|
|
3988
4354
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
3989
4355
|
spec: entry.spec,
|
|
3990
4356
|
rewritable: entry.spec !== ""
|
|
@@ -4034,11 +4400,11 @@ function stripQuotes(value) {
|
|
|
4034
4400
|
}
|
|
4035
4401
|
function collectNuget(workspaceRoot) {
|
|
4036
4402
|
const sites = [];
|
|
4037
|
-
const csprojPaths = (0,
|
|
4403
|
+
const csprojPaths = (0, import_node_fs12.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
4038
4404
|
for (const relativePath of csprojPaths) {
|
|
4039
4405
|
let content;
|
|
4040
4406
|
try {
|
|
4041
|
-
content = (0,
|
|
4407
|
+
content = (0, import_node_fs12.readFileSync)((0, import_node_path16.join)(workspaceRoot, relativePath), "utf8");
|
|
4042
4408
|
} catch {
|
|
4043
4409
|
continue;
|
|
4044
4410
|
}
|
|
@@ -4047,7 +4413,7 @@ function collectNuget(workspaceRoot) {
|
|
|
4047
4413
|
name: entry.name,
|
|
4048
4414
|
ecosystem: "nuget",
|
|
4049
4415
|
project: projectOf(relativePath),
|
|
4050
|
-
manifestPath: (0,
|
|
4416
|
+
manifestPath: (0, import_node_path16.join)(workspaceRoot, relativePath),
|
|
4051
4417
|
section: "dep",
|
|
4052
4418
|
spec: entry.spec,
|
|
4053
4419
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -4072,13 +4438,13 @@ function csprojPackageReferences(content) {
|
|
|
4072
4438
|
return entries;
|
|
4073
4439
|
}
|
|
4074
4440
|
function collectGo(workspaceRoot) {
|
|
4075
|
-
const manifestPath = (0,
|
|
4441
|
+
const manifestPath = (0, import_node_path16.join)(workspaceRoot, "go.mod");
|
|
4076
4442
|
if (!fileExists(manifestPath)) {
|
|
4077
4443
|
return [];
|
|
4078
4444
|
}
|
|
4079
4445
|
let content;
|
|
4080
4446
|
try {
|
|
4081
|
-
content = (0,
|
|
4447
|
+
content = (0, import_node_fs12.readFileSync)(manifestPath, "utf8");
|
|
4082
4448
|
} catch {
|
|
4083
4449
|
return [];
|
|
4084
4450
|
}
|
|
@@ -4135,7 +4501,7 @@ function rewriteSpec(site, spec) {
|
|
|
4135
4501
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
4136
4502
|
return true;
|
|
4137
4503
|
}
|
|
4138
|
-
const before = (0,
|
|
4504
|
+
const before = (0, import_node_fs12.readFileSync)(site.manifestPath, "utf8");
|
|
4139
4505
|
const after = (() => {
|
|
4140
4506
|
switch (site.ecosystem) {
|
|
4141
4507
|
case "pip": {
|
|
@@ -4191,13 +4557,13 @@ function escapeForRegex(value) {
|
|
|
4191
4557
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
4192
4558
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
4193
4559
|
return ["apps", "libs", "packages"].some(
|
|
4194
|
-
(directory) => fileExists((0,
|
|
4560
|
+
(directory) => fileExists((0, import_node_path16.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
4195
4561
|
);
|
|
4196
4562
|
}
|
|
4197
4563
|
function isAliasedInstall(workspaceRoot, name) {
|
|
4198
4564
|
try {
|
|
4199
4565
|
const installed = readJson(
|
|
4200
|
-
(0,
|
|
4566
|
+
(0, import_node_path16.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
4201
4567
|
);
|
|
4202
4568
|
return installed.name !== void 0 && installed.name !== name;
|
|
4203
4569
|
} catch {
|
|
@@ -4208,14 +4574,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
4208
4574
|
if (ecosystem === "npm") {
|
|
4209
4575
|
try {
|
|
4210
4576
|
return readJson(
|
|
4211
|
-
(0,
|
|
4577
|
+
(0, import_node_path16.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
4212
4578
|
).version;
|
|
4213
4579
|
} catch {
|
|
4214
4580
|
return void 0;
|
|
4215
4581
|
}
|
|
4216
4582
|
}
|
|
4217
4583
|
if (ecosystem === "pub") {
|
|
4218
|
-
const lockPath = (0,
|
|
4584
|
+
const lockPath = (0, import_node_path16.join)(workspaceRoot, "pubspec.lock");
|
|
4219
4585
|
if (!fileExists(lockPath)) {
|
|
4220
4586
|
return void 0;
|
|
4221
4587
|
}
|
|
@@ -4223,7 +4589,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
4223
4589
|
const match = new RegExp(
|
|
4224
4590
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
4225
4591
|
"m"
|
|
4226
|
-
).exec((0,
|
|
4592
|
+
).exec((0, import_node_fs12.readFileSync)(lockPath, "utf8"));
|
|
4227
4593
|
return match?.[1];
|
|
4228
4594
|
} catch {
|
|
4229
4595
|
return void 0;
|
|
@@ -4415,7 +4781,7 @@ function describe(finding) {
|
|
|
4415
4781
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
4416
4782
|
}
|
|
4417
4783
|
function runSync(workspaceRoot, options) {
|
|
4418
|
-
if (!fileExists((0,
|
|
4784
|
+
if (!fileExists((0, import_node_path17.join)(workspaceRoot, "nx.json"))) {
|
|
4419
4785
|
throw new Error(
|
|
4420
4786
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
4421
4787
|
);
|
|
@@ -4465,7 +4831,7 @@ function runSync(workspaceRoot, options) {
|
|
|
4465
4831
|
}
|
|
4466
4832
|
|
|
4467
4833
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
4468
|
-
var
|
|
4834
|
+
var import_node_path18 = require("path");
|
|
4469
4835
|
var import_prompts2 = require("@inquirer/prompts");
|
|
4470
4836
|
|
|
4471
4837
|
// src/dependency-management/registry.client.ts
|
|
@@ -4748,7 +5114,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
4748
5114
|
function hasPythonInstallScript(workspaceRoot) {
|
|
4749
5115
|
try {
|
|
4750
5116
|
const manifest = readJson(
|
|
4751
|
-
(0,
|
|
5117
|
+
(0, import_node_path18.join)(workspaceRoot, "package.json")
|
|
4752
5118
|
);
|
|
4753
5119
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
4754
5120
|
} catch {
|
|
@@ -4764,7 +5130,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
4764
5130
|
}
|
|
4765
5131
|
}
|
|
4766
5132
|
async function runUp(workspaceRoot, options) {
|
|
4767
|
-
if (!fileExists((0,
|
|
5133
|
+
if (!fileExists((0, import_node_path18.join)(workspaceRoot, "nx.json"))) {
|
|
4768
5134
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
4769
5135
|
}
|
|
4770
5136
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -4835,11 +5201,12 @@ var PROJECT_KINDS = [
|
|
|
4835
5201
|
"csharp-app",
|
|
4836
5202
|
"csharp-function-app",
|
|
4837
5203
|
"csharp-lib",
|
|
4838
|
-
"csharp-internal-lib"
|
|
5204
|
+
"csharp-internal-lib",
|
|
5205
|
+
"vscode-extension"
|
|
4839
5206
|
];
|
|
4840
5207
|
async function runAdd(kind, name, options) {
|
|
4841
5208
|
const workspaceRoot = process.cwd();
|
|
4842
|
-
if (!fileExists((0,
|
|
5209
|
+
if (!fileExists((0, import_node_path19.join)(workspaceRoot, "nx.json"))) {
|
|
4843
5210
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
4844
5211
|
}
|
|
4845
5212
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -4890,8 +5257,8 @@ async function runAdd(kind, name, options) {
|
|
|
4890
5257
|
],
|
|
4891
5258
|
workspaceRoot
|
|
4892
5259
|
);
|
|
4893
|
-
markPrivate((0,
|
|
4894
|
-
renameScaffoldPlaceholder((0,
|
|
5260
|
+
markPrivate((0, import_node_path19.join)(workspaceRoot, "libs", resolvedName, "package.json"));
|
|
5261
|
+
renameScaffoldPlaceholder((0, import_node_path19.join)(workspaceRoot, "libs", resolvedName), resolvedName);
|
|
4895
5262
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
4896
5263
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
4897
5264
|
break;
|
|
@@ -4956,6 +5323,13 @@ async function runAdd(kind, name, options) {
|
|
|
4956
5323
|
addCsharpInternalLib(workspaceRoot, resolvedName);
|
|
4957
5324
|
break;
|
|
4958
5325
|
}
|
|
5326
|
+
case "vscode-extension": {
|
|
5327
|
+
addVscodeExtension(workspaceRoot, resolvedName, stack, {
|
|
5328
|
+
publisher: options.publisher,
|
|
5329
|
+
sidecar: options.sidecar
|
|
5330
|
+
});
|
|
5331
|
+
break;
|
|
5332
|
+
}
|
|
4959
5333
|
case "python-vendor": {
|
|
4960
5334
|
await addPythonVendor(workspaceRoot, resolvedName, options, kindProvided);
|
|
4961
5335
|
syncProjectReferences(workspaceRoot);
|
|
@@ -4976,7 +5350,7 @@ async function runAdd(kind, name, options) {
|
|
|
4976
5350
|
}
|
|
4977
5351
|
function readWorkspaceStack(workspaceRoot) {
|
|
4978
5352
|
const nxJson = readJson(
|
|
4979
|
-
(0,
|
|
5353
|
+
(0, import_node_path19.join)(workspaceRoot, "nx.json")
|
|
4980
5354
|
);
|
|
4981
5355
|
const stack = nxJson.mnci?.stack;
|
|
4982
5356
|
return {
|
|
@@ -4985,15 +5359,15 @@ function readWorkspaceStack(workspaceRoot) {
|
|
|
4985
5359
|
}
|
|
4986
5360
|
|
|
4987
5361
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
4988
|
-
var
|
|
4989
|
-
var
|
|
5362
|
+
var import_node_fs13 = require("fs");
|
|
5363
|
+
var import_node_path20 = require("path");
|
|
4990
5364
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
4991
5365
|
function toPosix2(path) {
|
|
4992
5366
|
return path.replaceAll("\\", "/");
|
|
4993
5367
|
}
|
|
4994
5368
|
function checkEslintConfigs(workspaceRoot) {
|
|
4995
|
-
const rootConfigs = (0,
|
|
4996
|
-
const projectConfigs = (0,
|
|
5369
|
+
const rootConfigs = (0, import_node_fs13.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
5370
|
+
const projectConfigs = (0, import_node_fs13.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
4997
5371
|
cwd: workspaceRoot
|
|
4998
5372
|
}).map((config) => toPosix2(config));
|
|
4999
5373
|
return [
|
|
@@ -5013,10 +5387,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
5013
5387
|
];
|
|
5014
5388
|
}
|
|
5015
5389
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
5016
|
-
const rules = (0,
|
|
5017
|
-
if (!(0,
|
|
5018
|
-
const entryPoint = (0,
|
|
5019
|
-
const source = (0,
|
|
5390
|
+
const rules = (0, import_node_path20.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
5391
|
+
if (!(0, import_node_fs13.existsSync)(rules)) return [];
|
|
5392
|
+
const entryPoint = (0, import_node_path20.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
5393
|
+
const source = (0, import_node_fs13.existsSync)(entryPoint) ? (0, import_node_fs13.readFileSync)(entryPoint, "utf8") : "";
|
|
5020
5394
|
return [
|
|
5021
5395
|
{
|
|
5022
5396
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -5029,7 +5403,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
5029
5403
|
function declaredDevDependencies(workspaceRoot) {
|
|
5030
5404
|
try {
|
|
5031
5405
|
const manifest = readJson(
|
|
5032
|
-
(0,
|
|
5406
|
+
(0, import_node_path20.join)(workspaceRoot, "package.json")
|
|
5033
5407
|
);
|
|
5034
5408
|
return manifest.devDependencies ?? {};
|
|
5035
5409
|
} catch {
|
|
@@ -5037,7 +5411,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
5037
5411
|
}
|
|
5038
5412
|
}
|
|
5039
5413
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
5040
|
-
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0,
|
|
5414
|
+
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0, import_node_path20.join)(workspaceRoot, file)));
|
|
5041
5415
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
5042
5416
|
const stale = [...files, ...declared];
|
|
5043
5417
|
if (stale.length === 0) {
|
|
@@ -5063,7 +5437,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
5063
5437
|
};
|
|
5064
5438
|
}
|
|
5065
5439
|
function checkResolvedEslint(workspaceRoot) {
|
|
5066
|
-
const manifestPath = (0,
|
|
5440
|
+
const manifestPath = (0, import_node_path20.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
5067
5441
|
if (!fileExists(manifestPath)) {
|
|
5068
5442
|
return void 0;
|
|
5069
5443
|
}
|
|
@@ -5081,11 +5455,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
5081
5455
|
}
|
|
5082
5456
|
}
|
|
5083
5457
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
5084
|
-
const npmrcPath = (0,
|
|
5458
|
+
const npmrcPath = (0, import_node_path20.join)(workspaceRoot, ".npmrc");
|
|
5085
5459
|
if (!registry || !fileExists(npmrcPath)) {
|
|
5086
5460
|
return void 0;
|
|
5087
5461
|
}
|
|
5088
|
-
const npmrc = (0,
|
|
5462
|
+
const npmrc = (0, import_node_fs13.readFileSync)(npmrcPath, "utf8");
|
|
5089
5463
|
if (registry.kind === "npm") {
|
|
5090
5464
|
return {
|
|
5091
5465
|
check: ".npmrc authenticates the public registry",
|
|
@@ -5102,11 +5476,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
5102
5476
|
};
|
|
5103
5477
|
}
|
|
5104
5478
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
5105
|
-
const npmrcPath = (0,
|
|
5479
|
+
const npmrcPath = (0, import_node_path20.join)(workspaceRoot, ".npmrc");
|
|
5106
5480
|
if (!fileExists(npmrcPath)) {
|
|
5107
5481
|
return void 0;
|
|
5108
5482
|
}
|
|
5109
|
-
const npmrc = (0,
|
|
5483
|
+
const npmrc = (0, import_node_fs13.readFileSync)(npmrcPath, "utf8");
|
|
5110
5484
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
5111
5485
|
const referenced = [
|
|
5112
5486
|
...new Set(
|
|
@@ -5130,13 +5504,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
5130
5504
|
};
|
|
5131
5505
|
}
|
|
5132
5506
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
5133
|
-
const npmrcPath = (0,
|
|
5134
|
-
const pipelinePath = (0,
|
|
5507
|
+
const npmrcPath = (0, import_node_path20.join)(workspaceRoot, ".npmrc");
|
|
5508
|
+
const pipelinePath = (0, import_node_path20.join)(workspaceRoot, "azure-pipelines.yml");
|
|
5135
5509
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
5136
5510
|
return void 0;
|
|
5137
5511
|
}
|
|
5138
|
-
const holdsCredentials = (0,
|
|
5139
|
-
const runsTask = (0,
|
|
5512
|
+
const holdsCredentials = (0, import_node_fs13.readFileSync)(npmrcPath, "utf8").split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).some((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
5513
|
+
const runsTask = (0, import_node_fs13.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
5140
5514
|
if (!holdsCredentials && !runsTask) {
|
|
5141
5515
|
return {
|
|
5142
5516
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -5181,13 +5555,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
5181
5555
|
}
|
|
5182
5556
|
function checkVersionActions(workspaceRoot) {
|
|
5183
5557
|
const candidates = [
|
|
5184
|
-
...(0,
|
|
5185
|
-
...(0,
|
|
5186
|
-
...(0,
|
|
5558
|
+
...(0, import_node_fs13.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
5559
|
+
...(0, import_node_fs13.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
5560
|
+
...(0, import_node_fs13.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
5187
5561
|
].map((manifest) => toPosix2(manifest));
|
|
5188
5562
|
return candidates.flatMap((manifest) => {
|
|
5189
5563
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
5190
|
-
const projectJsonPath = (0,
|
|
5564
|
+
const projectJsonPath = (0, import_node_path20.join)(workspaceRoot, projectRoot, "project.json");
|
|
5191
5565
|
let hasOverride = false;
|
|
5192
5566
|
try {
|
|
5193
5567
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -5216,7 +5590,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
5216
5590
|
]) {
|
|
5217
5591
|
try {
|
|
5218
5592
|
const targets = extract(
|
|
5219
|
-
readJson((0,
|
|
5593
|
+
readJson((0, import_node_path20.join)(workspaceRoot, projectRoot, file))
|
|
5220
5594
|
);
|
|
5221
5595
|
if (targets && typeof targets === "object") {
|
|
5222
5596
|
sources.push({
|
|
@@ -5232,8 +5606,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
5232
5606
|
function checkTargetFilesExist(workspaceRoot) {
|
|
5233
5607
|
const projectRoots = new Set(
|
|
5234
5608
|
[
|
|
5235
|
-
...(0,
|
|
5236
|
-
...(0,
|
|
5609
|
+
...(0, import_node_fs13.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
5610
|
+
...(0, import_node_fs13.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
5237
5611
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
5238
5612
|
);
|
|
5239
5613
|
return [...projectRoots].flatMap(
|
|
@@ -5248,7 +5622,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
5248
5622
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
5249
5623
|
const value = target?.options?.[option];
|
|
5250
5624
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
5251
|
-
if (!checkable || fileExists((0,
|
|
5625
|
+
if (!checkable || fileExists((0, import_node_path20.join)(workspaceRoot, value))) {
|
|
5252
5626
|
return [];
|
|
5253
5627
|
}
|
|
5254
5628
|
return [
|
|
@@ -5270,7 +5644,7 @@ function checkSync(workspaceRoot) {
|
|
|
5270
5644
|
};
|
|
5271
5645
|
}
|
|
5272
5646
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
5273
|
-
const manifestPath = (0,
|
|
5647
|
+
const manifestPath = (0, import_node_path20.join)(workspaceRoot, "package.json");
|
|
5274
5648
|
if (!fileExists(manifestPath)) {
|
|
5275
5649
|
return void 0;
|
|
5276
5650
|
}
|
|
@@ -5290,14 +5664,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
5290
5664
|
};
|
|
5291
5665
|
}
|
|
5292
5666
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
5293
|
-
const configs = (0,
|
|
5667
|
+
const configs = (0, import_node_fs13.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5294
5668
|
cwd: workspaceRoot
|
|
5295
5669
|
}).map((config) => toPosix2(config));
|
|
5296
5670
|
return configs.flatMap((relativePath) => {
|
|
5297
|
-
const configPath = (0,
|
|
5671
|
+
const configPath = (0, import_node_path20.join)(workspaceRoot, relativePath);
|
|
5298
5672
|
let config;
|
|
5299
5673
|
try {
|
|
5300
|
-
config = (0,
|
|
5674
|
+
config = (0, import_node_fs13.readFileSync)(configPath, "utf8");
|
|
5301
5675
|
} catch {
|
|
5302
5676
|
return [];
|
|
5303
5677
|
}
|
|
@@ -5312,11 +5686,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
5312
5686
|
});
|
|
5313
5687
|
}
|
|
5314
5688
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
5315
|
-
const configs = (0,
|
|
5689
|
+
const configs = (0, import_node_fs13.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5316
5690
|
cwd: workspaceRoot
|
|
5317
5691
|
}).map((config) => toPosix2(config));
|
|
5318
5692
|
return configs.flatMap((relativePath) => {
|
|
5319
|
-
const configPath = (0,
|
|
5693
|
+
const configPath = (0, import_node_path20.join)(workspaceRoot, relativePath);
|
|
5320
5694
|
if (!fileExists(configPath)) {
|
|
5321
5695
|
return [];
|
|
5322
5696
|
}
|
|
@@ -5350,7 +5724,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
5350
5724
|
});
|
|
5351
5725
|
}
|
|
5352
5726
|
function collectFindings(workspaceRoot) {
|
|
5353
|
-
const nxJsonPath = (0,
|
|
5727
|
+
const nxJsonPath = (0, import_node_path20.join)(workspaceRoot, "nx.json");
|
|
5354
5728
|
if (!fileExists(nxJsonPath)) {
|
|
5355
5729
|
throw new Error(
|
|
5356
5730
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -5395,8 +5769,8 @@ function runDoctor(workspaceRoot) {
|
|
|
5395
5769
|
}
|
|
5396
5770
|
|
|
5397
5771
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
5398
|
-
var
|
|
5399
|
-
var
|
|
5772
|
+
var import_node_fs14 = require("fs");
|
|
5773
|
+
var import_node_path21 = require("path");
|
|
5400
5774
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
5401
5775
|
var AGENT_AND_CI_ENTRIES = [
|
|
5402
5776
|
"AGENTS.md",
|
|
@@ -5427,13 +5801,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
5427
5801
|
"packages"
|
|
5428
5802
|
];
|
|
5429
5803
|
function assertAdoptableDirectory(target) {
|
|
5430
|
-
if (!(0,
|
|
5804
|
+
if (!(0, import_node_fs14.existsSync)(target)) {
|
|
5431
5805
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
5432
5806
|
}
|
|
5433
|
-
if (!(0,
|
|
5807
|
+
if (!(0, import_node_fs14.statSync)(target).isDirectory()) {
|
|
5434
5808
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
5435
5809
|
}
|
|
5436
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
5810
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs14.existsSync)((0, import_node_path21.join)(target, entry)));
|
|
5437
5811
|
if (blockers.length > 0) {
|
|
5438
5812
|
throw new Error(
|
|
5439
5813
|
`--into '${target}' already holds ${blockers.join(", ")}, so it is a project already. Use \`mnci upgrade\` to re-apply the overlay to an existing workspace, or point --into at an empty checkout.`
|
|
@@ -5441,15 +5815,15 @@ function assertAdoptableDirectory(target) {
|
|
|
5441
5815
|
}
|
|
5442
5816
|
}
|
|
5443
5817
|
function mergeGitignore(generatedFile, targetFile) {
|
|
5444
|
-
const existing = (0,
|
|
5818
|
+
const existing = (0, import_node_fs14.readFileSync)(targetFile, "utf8");
|
|
5445
5819
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
5446
|
-
const additions = (0,
|
|
5820
|
+
const additions = (0, import_node_fs14.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
5447
5821
|
const trimmed = line.trim();
|
|
5448
5822
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
5449
5823
|
});
|
|
5450
5824
|
if (additions.length === 0) return false;
|
|
5451
5825
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
5452
|
-
(0,
|
|
5826
|
+
(0, import_node_fs14.writeFileSync)(
|
|
5453
5827
|
targetFile,
|
|
5454
5828
|
`${existing}${separator}
|
|
5455
5829
|
# Added by mnci (Nx workspace)
|
|
@@ -5459,9 +5833,9 @@ ${additions.join("\n")}
|
|
|
5459
5833
|
return true;
|
|
5460
5834
|
}
|
|
5461
5835
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
5462
|
-
const entries = (0,
|
|
5836
|
+
const entries = (0, import_node_fs14.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
5463
5837
|
const collisions = entries.filter(
|
|
5464
|
-
(entry) => (0,
|
|
5838
|
+
(entry) => (0, import_node_fs14.existsSync)((0, import_node_path21.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
5465
5839
|
);
|
|
5466
5840
|
if (collisions.length > 0) {
|
|
5467
5841
|
throw new Error(
|
|
@@ -5470,28 +5844,28 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
5470
5844
|
}
|
|
5471
5845
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
5472
5846
|
for (const entry of entries) {
|
|
5473
|
-
const from = (0,
|
|
5474
|
-
const to = (0,
|
|
5475
|
-
if (entry === ".gitignore" && (0,
|
|
5847
|
+
const from = (0, import_node_path21.join)(generatedRoot, entry);
|
|
5848
|
+
const to = (0, import_node_path21.join)(target, entry);
|
|
5849
|
+
if (entry === ".gitignore" && (0, import_node_fs14.existsSync)(to)) {
|
|
5476
5850
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
5477
5851
|
result.kept.push(entry);
|
|
5478
5852
|
continue;
|
|
5479
5853
|
}
|
|
5480
|
-
if ((0,
|
|
5854
|
+
if ((0, import_node_fs14.existsSync)(to)) {
|
|
5481
5855
|
result.kept.push(entry);
|
|
5482
5856
|
continue;
|
|
5483
5857
|
}
|
|
5484
|
-
(0,
|
|
5858
|
+
(0, import_node_fs14.cpSync)(from, to, { recursive: true });
|
|
5485
5859
|
result.copied.push(entry);
|
|
5486
5860
|
}
|
|
5487
|
-
(0,
|
|
5861
|
+
(0, import_node_fs14.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
5488
5862
|
return result;
|
|
5489
5863
|
}
|
|
5490
5864
|
|
|
5491
5865
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
5492
|
-
var
|
|
5866
|
+
var import_node_fs15 = require("fs");
|
|
5493
5867
|
var import_node_os = require("os");
|
|
5494
|
-
var
|
|
5868
|
+
var import_node_path22 = require("path");
|
|
5495
5869
|
function nxCloudProviderValue(ci) {
|
|
5496
5870
|
return ci === "azure" ? "azure" : "github";
|
|
5497
5871
|
}
|
|
@@ -5527,9 +5901,9 @@ async function resolveRegistry(options) {
|
|
|
5527
5901
|
return await promptRegistry();
|
|
5528
5902
|
}
|
|
5529
5903
|
async function runNew(name, options) {
|
|
5530
|
-
const adoptTarget = options.into === void 0 ? void 0 : (0,
|
|
5904
|
+
const adoptTarget = options.into === void 0 ? void 0 : (0, import_node_path22.resolve)(process.cwd(), options.into);
|
|
5531
5905
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
5532
|
-
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0,
|
|
5906
|
+
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0, import_node_path22.basename)(adoptTarget));
|
|
5533
5907
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
5534
5908
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
5535
5909
|
const registry = await resolveRegistry(options);
|
|
@@ -5542,8 +5916,8 @@ async function runNew(name, options) {
|
|
|
5542
5916
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
5543
5917
|
const stack = await resolveStack(options);
|
|
5544
5918
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
5545
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
5546
|
-
let workspaceRoot = (0,
|
|
5919
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs15.mkdtempSync)((0, import_node_path22.join)((0, import_node_os.tmpdir)(), "mnci-new-"));
|
|
5920
|
+
let workspaceRoot = (0, import_node_path22.join)(stagingParent, workspaceName);
|
|
5547
5921
|
try {
|
|
5548
5922
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
5549
5923
|
runNpx(
|
|
@@ -5566,7 +5940,7 @@ async function runNew(name, options) {
|
|
|
5566
5940
|
workspaceRoot = adoptTarget;
|
|
5567
5941
|
}
|
|
5568
5942
|
} finally {
|
|
5569
|
-
if (adoptTarget !== void 0) (0,
|
|
5943
|
+
if (adoptTarget !== void 0) (0, import_node_fs15.rmSync)(stagingParent, { recursive: true, force: true });
|
|
5570
5944
|
}
|
|
5571
5945
|
logger.step(
|
|
5572
5946
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -5576,8 +5950,8 @@ async function runNew(name, options) {
|
|
|
5576
5950
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
5577
5951
|
logger.detail
|
|
5578
5952
|
);
|
|
5579
|
-
(0,
|
|
5580
|
-
(0,
|
|
5953
|
+
(0, import_node_fs15.rmSync)((0, import_node_path22.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
5954
|
+
(0, import_node_fs15.rmSync)((0, import_node_path22.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
5581
5955
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
5582
5956
|
const installStatus = runShell(
|
|
5583
5957
|
"npm",
|
|
@@ -5601,18 +5975,19 @@ async function runNew(name, options) {
|
|
|
5601
5975
|
" # go-app, go-function-app, go-lib, go-internal-lib,"
|
|
5602
5976
|
);
|
|
5603
5977
|
logger.info(
|
|
5604
|
-
" # flutter-app, flutter-lib, flutter-internal-lib"
|
|
5978
|
+
" # flutter-app, flutter-lib, flutter-internal-lib,"
|
|
5605
5979
|
);
|
|
5980
|
+
logger.info(" # vscode-extension");
|
|
5606
5981
|
logger.info(' git add -A && git commit -m "feat: initial workspace"');
|
|
5607
5982
|
}
|
|
5608
5983
|
|
|
5609
5984
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
5610
|
-
var
|
|
5985
|
+
var import_node_path24 = require("path");
|
|
5611
5986
|
var import_prompts4 = require("@inquirer/prompts");
|
|
5612
5987
|
|
|
5613
5988
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
5614
|
-
var
|
|
5615
|
-
var
|
|
5989
|
+
var import_node_fs16 = require("fs");
|
|
5990
|
+
var import_node_path23 = require("path");
|
|
5616
5991
|
function resolveRegistry2(options, persisted) {
|
|
5617
5992
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
5618
5993
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -5641,7 +6016,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
5641
6016
|
return persisted.workspaceName;
|
|
5642
6017
|
}
|
|
5643
6018
|
try {
|
|
5644
|
-
const existing = (0,
|
|
6019
|
+
const existing = (0, import_node_fs16.readdirSync)(workspaceRoot).find(
|
|
5645
6020
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
5646
6021
|
);
|
|
5647
6022
|
if (existing) {
|
|
@@ -5649,11 +6024,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
5649
6024
|
}
|
|
5650
6025
|
} catch {
|
|
5651
6026
|
}
|
|
5652
|
-
return (0,
|
|
6027
|
+
return (0, import_node_path23.basename)(workspaceRoot);
|
|
5653
6028
|
}
|
|
5654
6029
|
function detectNpmAuth(workspaceRoot) {
|
|
5655
6030
|
try {
|
|
5656
|
-
return (0,
|
|
6031
|
+
return (0, import_node_fs16.readFileSync)((0, import_node_path23.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
5657
6032
|
} catch {
|
|
5658
6033
|
return void 0;
|
|
5659
6034
|
}
|
|
@@ -5700,7 +6075,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
5700
6075
|
};
|
|
5701
6076
|
}
|
|
5702
6077
|
function runUpgrade(workspaceRoot, options) {
|
|
5703
|
-
if (!fileExists((0,
|
|
6078
|
+
if (!fileExists((0, import_node_path23.join)(workspaceRoot, "nx.json"))) {
|
|
5704
6079
|
throw new Error(
|
|
5705
6080
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
5706
6081
|
);
|
|
@@ -5730,6 +6105,10 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
5730
6105
|
logger.detail(`updated ${path}`);
|
|
5731
6106
|
}
|
|
5732
6107
|
}
|
|
6108
|
+
if (refreshVscodeExtensionScript(workspaceRoot)) {
|
|
6109
|
+
logger.step("Updating the VS Code extension packaging script");
|
|
6110
|
+
logger.detail(`updated ${VSCODE_EXTENSION_SCRIPT_PATH}`);
|
|
6111
|
+
}
|
|
5733
6112
|
const upgradedDtsPlugins = upgradeDeclarationSpecifierPlugins(workspaceRoot);
|
|
5734
6113
|
if (upgradedDtsPlugins.length > 0) {
|
|
5735
6114
|
logger.step("Upgrading declaration specifiers to resolve under nodenext");
|
|
@@ -5746,7 +6125,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
5746
6125
|
|
|
5747
6126
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
5748
6127
|
async function runInteractive() {
|
|
5749
|
-
const inWorkspace = fileExists((0,
|
|
6128
|
+
const inWorkspace = fileExists((0, import_node_path24.join)(process.cwd(), "nx.json"));
|
|
5750
6129
|
const choiceNew = { name: "Create a new monorepo", value: "new" };
|
|
5751
6130
|
const choiceAdd = { name: "Add a project to this workspace", value: "add" };
|
|
5752
6131
|
const choiceUpgrade = {
|
|
@@ -5767,8 +6146,8 @@ async function runInteractive() {
|
|
|
5767
6146
|
}
|
|
5768
6147
|
|
|
5769
6148
|
// src/cli-version/check-for-update.use-case.ts
|
|
5770
|
-
var
|
|
5771
|
-
var
|
|
6149
|
+
var import_node_fs17 = require("fs");
|
|
6150
|
+
var import_node_path25 = require("path");
|
|
5772
6151
|
var import_cross_spawn2 = __toESM(require("cross-spawn"));
|
|
5773
6152
|
var PACKAGE_NAME = "@mnci/cli";
|
|
5774
6153
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
@@ -5824,8 +6203,8 @@ function releaseTriple(version) {
|
|
|
5824
6203
|
}
|
|
5825
6204
|
function readCliVersion(packageDirectory) {
|
|
5826
6205
|
try {
|
|
5827
|
-
const manifestPath = (0,
|
|
5828
|
-
const manifest = JSON.parse((0,
|
|
6206
|
+
const manifestPath = (0, import_node_path25.join)(packageDirectory, "..", "package.json");
|
|
6207
|
+
const manifest = JSON.parse((0, import_node_fs17.readFileSync)(manifestPath, "utf8"));
|
|
5829
6208
|
return manifest.version ?? "0.0.0";
|
|
5830
6209
|
} catch {
|
|
5831
6210
|
return "0.0.0";
|
|
@@ -5880,6 +6259,12 @@ function buildProgram(cliVersion) {
|
|
|
5880
6259
|
).option(
|
|
5881
6260
|
"--lib <name>",
|
|
5882
6261
|
"python-vendor only: the internal Python library (libs/<name>) to vendor into <name>"
|
|
6262
|
+
).option(
|
|
6263
|
+
"--publisher <id>",
|
|
6264
|
+
"vscode-extension only: the Marketplace publisher id (defaults to the workspace scope without @)"
|
|
6265
|
+
).option(
|
|
6266
|
+
"--sidecar <go-app>",
|
|
6267
|
+
"vscode-extension only: a go-app whose six-platform build ships in the extension, one .vsix per platform"
|
|
5883
6268
|
).action(
|
|
5884
6269
|
async (kind, name, options) => {
|
|
5885
6270
|
await runAdd(kind, name, options);
|