@mnci/cli 4.13.1 → 4.14.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 +53 -0
- package/dist/cli.js +405 -219
- 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_path20 = require("path");
|
|
42
42
|
var import_prompts3 = require("@inquirer/prompts");
|
|
43
43
|
|
|
44
44
|
// src/nx-workspace/nx.client.ts
|
|
@@ -434,11 +434,12 @@ ${feedShortKey}:email=npm-requires-this-and-never-uses-it
|
|
|
434
434
|
`;
|
|
435
435
|
}
|
|
436
436
|
var VSCODE_EXTENSION_TAG = "type:vscode-extension";
|
|
437
|
+
var GO_RELEASE_TAG = "release:go";
|
|
437
438
|
function releaseConfig(ci) {
|
|
438
439
|
const githubReleases = ci === "github";
|
|
439
440
|
return {
|
|
440
441
|
projectsRelationship: "independent",
|
|
441
|
-
projects: ["packages/*", "python-packages/*", `tag:${VSCODE_EXTENSION_TAG}`, "!tag:type:go-lib"],
|
|
442
|
+
projects: ["packages/*", "python-packages/*", `tag:${VSCODE_EXTENSION_TAG}`, `tag:${GO_RELEASE_TAG}`, "!tag:type:go-lib"],
|
|
442
443
|
releaseTag: { pattern: "{projectName}@{version}" },
|
|
443
444
|
git: { commit: false, tag: true, push: githubReleases },
|
|
444
445
|
version: {
|
|
@@ -1046,7 +1047,7 @@ function pypiReleasePreflight(registryKind) {
|
|
|
1046
1047
|
}
|
|
1047
1048
|
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)}"`;
|
|
1048
1049
|
function releaseGuard(pythonPublishEnv, nugetPublishEnv) {
|
|
1049
|
-
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)"`;
|
|
1050
|
+
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 goCount=fs.globSync('apps/*/project.json').filter(p=>{try{return(JSON.parse(fs.readFileSync(p,'utf8')).tags||[]).includes('${GO_RELEASE_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;const hasGo=goCount>0;if(!hasNpm&&!hasPython&&!hasCsharp&&!hasDart&&!hasVscode&&!hasGo){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+goCount;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)"`;
|
|
1050
1051
|
}
|
|
1051
1052
|
var PYPI_TOKEN_VARIABLE = "PYPI_TOKEN";
|
|
1052
1053
|
var AZURE_PAT_VARIABLE = "PAT";
|
|
@@ -1667,7 +1668,18 @@ ${npmAuthPreflight(registryKind) ? `
|
|
|
1667
1668
|
VSCE_AUTH: \${{ vars.AZURE_CLIENT_ID != '' && 'entra' || '' }}
|
|
1668
1669
|
VSCE_PAT: \${{ secrets.VSCE_PAT }}${githubReleases ? `
|
|
1669
1670
|
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}` : ""}
|
|
1670
|
-
${githubReleases ?
|
|
1671
|
+
${githubReleases ? `
|
|
1672
|
+
# A releasable Go app (mnci add go-app --release) is versioned by its git
|
|
1673
|
+
# tag, and its per-platform zips are attached to the GitHub Release the step
|
|
1674
|
+
# above just created. Built here, after tagging, with VERSION set to the tag's
|
|
1675
|
+
# version so the binary reports it. A run that released no Go app uploads
|
|
1676
|
+
# nothing, and a workspace without one skips the step.
|
|
1677
|
+
- run: node tools/go-app-release.cjs assets
|
|
1678
|
+
name: Attach the per-platform zips to the GitHub Release (releasable Go apps)
|
|
1679
|
+
if: \${{ ${onMain} && hashFiles('tools/go-app-release.cjs') != '' }}
|
|
1680
|
+
env:
|
|
1681
|
+
GH_TOKEN: \${{ secrets.GITHUB_TOKEN }}
|
|
1682
|
+
` : `
|
|
1671
1683
|
# nx release's own git push (release.git.push) is deliberately left off: it
|
|
1672
1684
|
# only runs when a remote GitHub/GitLab Release is configured, which this
|
|
1673
1685
|
# workflow never does, so it would never push the tag the step above just
|
|
@@ -2605,8 +2617,169 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
2605
2617
|
}
|
|
2606
2618
|
|
|
2607
2619
|
// src/project-scaffolding/go.use-case.ts
|
|
2620
|
+
var import_node_fs6 = require("fs");
|
|
2621
|
+
var import_node_path7 = require("path");
|
|
2622
|
+
|
|
2623
|
+
// src/project-scaffolding/go-release.use-case.ts
|
|
2608
2624
|
var import_node_fs5 = require("fs");
|
|
2609
2625
|
var import_node_path6 = require("path");
|
|
2626
|
+
var GO_RELEASE_SCRIPT_PATH = "tools/go-app-release.cjs";
|
|
2627
|
+
var GO_RELEASE_SCRIPT = String.raw`#!/usr/bin/env node
|
|
2628
|
+
// Written by mnci: 'mnci add go-app --release' creates it and 'mnci upgrade'
|
|
2629
|
+
// rewrites it, so local edits do not survive an upgrade.
|
|
2630
|
+
//
|
|
2631
|
+
// A releasable Go app (tag release:go) is versioned from its git tag, with no
|
|
2632
|
+
// manifest, and its per-platform zips are attached to its GitHub Release:
|
|
2633
|
+
// release.version.versionActions this file, loaded by 'nx release'
|
|
2634
|
+
// node tools/go-app-release.cjs assets
|
|
2635
|
+
'use strict'
|
|
2636
|
+
const { spawnSync } = require('node:child_process')
|
|
2637
|
+
const { existsSync, readdirSync } = require('node:fs')
|
|
2638
|
+
const { dirname, join } = require('node:path')
|
|
2639
|
+
const { VersionActions } = require('nx/release')
|
|
2640
|
+
|
|
2641
|
+
const FIRST_RELEASE_BASE = '0.0.0'
|
|
2642
|
+
|
|
2643
|
+
class GoAppVersionActions extends VersionActions {
|
|
2644
|
+
validManifestFilenames = null
|
|
2645
|
+
|
|
2646
|
+
async validate () {
|
|
2647
|
+
// Nothing on disk to check: there is no manifest.
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
async readCurrentVersionFromSourceManifest () {
|
|
2651
|
+
// Reached only as the fallback of the git-tag resolver, i.e. before the first tag.
|
|
2652
|
+
return { currentVersion: FIRST_RELEASE_BASE, manifestPath: 'none (a Go app is versioned by its git tag)' }
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
async readCurrentVersionFromRegistry () {
|
|
2656
|
+
return null
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
async readCurrentVersionOfDependency () {
|
|
2660
|
+
return { currentVersion: null, dependencyCollection: null }
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2663
|
+
async updateProjectVersion () {
|
|
2664
|
+
return []
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
async updateProjectDependencies () {
|
|
2668
|
+
return []
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
module.exports = GoAppVersionActions
|
|
2673
|
+
|
|
2674
|
+
function fail (message) {
|
|
2675
|
+
console.error(message)
|
|
2676
|
+
process.exit(1)
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
function run (command, args, env) {
|
|
2680
|
+
const result = spawnSync(command, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'], env: { ...process.env, ...env }, shell: false })
|
|
2681
|
+
if (result.status !== 0) fail(command + ' ' + args.join(' ') + ' failed (exit ' + result.status + ')')
|
|
2682
|
+
|
|
2683
|
+
return result.stdout
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
function nx (args, env) {
|
|
2687
|
+
const manifest = require.resolve('nx/package.json')
|
|
2688
|
+
const bin = require(manifest).bin
|
|
2689
|
+
const entry = typeof bin === 'string' ? bin : bin.nx
|
|
2690
|
+
|
|
2691
|
+
return run(process.execPath, [join(dirname(manifest), entry), ...args], env)
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
function releasableApps () {
|
|
2695
|
+
return JSON.parse(nx(['show', 'projects', '--projects', 'tag:release:go', '--json'])).filter(Boolean)
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
function attachAssets () {
|
|
2699
|
+
const apps = releasableApps()
|
|
2700
|
+
if (apps.length === 0) {
|
|
2701
|
+
console.log('No releasable Go app - nothing to attach.')
|
|
2702
|
+
|
|
2703
|
+
return
|
|
2704
|
+
}
|
|
2705
|
+
const tags = run('git', ['tag', '--points-at', 'HEAD']).split(/\r?\n/).filter(Boolean)
|
|
2706
|
+
let attached = 0
|
|
2707
|
+
for (const app of apps) {
|
|
2708
|
+
const tag = tags.find(each => each.startsWith(app + '@'))
|
|
2709
|
+
if (!tag) {
|
|
2710
|
+
console.log(app + ': not released by this run - skipping.')
|
|
2711
|
+
continue
|
|
2712
|
+
}
|
|
2713
|
+
const version = tag.slice(app.length + 1)
|
|
2714
|
+
console.log(app + ': building the six platforms as ' + version)
|
|
2715
|
+
nx(['run', app + ':package-all'], { VERSION: version })
|
|
2716
|
+
const prefix = 'go-app-' + app + '-'
|
|
2717
|
+
const zips = existsSync('dist/drop') ? readdirSync('dist/drop').filter(each => each.startsWith(prefix) && each.endsWith('.zip')) : []
|
|
2718
|
+
if (zips.length === 0) fail(app + ': package-all produced no ' + prefix + '*.zip in dist/drop.')
|
|
2719
|
+
const upload = spawnSync('gh', ['release', 'upload', tag, ...zips.map(each => join('dist/drop', each)), '--clobber'], { stdio: 'inherit', shell: process.platform === 'win32' })
|
|
2720
|
+
if (upload.status !== 0) fail(app + ': could not attach the zips to the ' + tag + ' release (exit ' + upload.status + ').')
|
|
2721
|
+
console.log(app + ': attached ' + zips.length + ' zips to ' + tag)
|
|
2722
|
+
attached += 1
|
|
2723
|
+
}
|
|
2724
|
+
console.log(attached + ' release(s) carry their platform zips.')
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
if (require.main === module) {
|
|
2728
|
+
if (process.argv[2] !== 'assets') fail('Usage: node tools/go-app-release.cjs assets')
|
|
2729
|
+
attachAssets()
|
|
2730
|
+
}
|
|
2731
|
+
`;
|
|
2732
|
+
var GO_RELEASE_PUBLISH_TARGET = {
|
|
2733
|
+
executor: "nx:run-commands",
|
|
2734
|
+
options: {
|
|
2735
|
+
command: `node -e "console.log('Published by its git tag; the platform zips are attached to the GitHub Release by tools/go-app-release.cjs assets.')"`
|
|
2736
|
+
}
|
|
2737
|
+
};
|
|
2738
|
+
function makeGoAppReleasable(workspaceRoot, name) {
|
|
2739
|
+
const projectJsonPath = (0, import_node_path6.join)(workspaceRoot, "apps", name, "project.json");
|
|
2740
|
+
if (!fileExists(projectJsonPath)) {
|
|
2741
|
+
throw new Error(`No Go app at apps/${name}: cannot make it releasable.`);
|
|
2742
|
+
}
|
|
2743
|
+
const project = readJson(projectJsonPath);
|
|
2744
|
+
writeFileEnsured(
|
|
2745
|
+
projectJsonPath,
|
|
2746
|
+
toJson({
|
|
2747
|
+
...project,
|
|
2748
|
+
tags: [.../* @__PURE__ */ new Set([...project.tags ?? [], GO_RELEASE_TAG])],
|
|
2749
|
+
targets: { ...project.targets, "nx-release-publish": project.targets?.["nx-release-publish"] ?? GO_RELEASE_PUBLISH_TARGET },
|
|
2750
|
+
release: {
|
|
2751
|
+
...project.release,
|
|
2752
|
+
version: {
|
|
2753
|
+
...project.release?.version,
|
|
2754
|
+
versionActions: GO_RELEASE_SCRIPT_PATH,
|
|
2755
|
+
currentVersionResolver: "git-tag"
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
})
|
|
2759
|
+
);
|
|
2760
|
+
writeFileEnsured((0, import_node_path6.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH), GO_RELEASE_SCRIPT);
|
|
2761
|
+
}
|
|
2762
|
+
function refreshGoReleaseScript(workspaceRoot) {
|
|
2763
|
+
const apps = (0, import_node_path6.join)(workspaceRoot, "apps");
|
|
2764
|
+
let entries;
|
|
2765
|
+
try {
|
|
2766
|
+
entries = (0, import_node_fs5.readdirSync)(apps);
|
|
2767
|
+
} catch {
|
|
2768
|
+
return false;
|
|
2769
|
+
}
|
|
2770
|
+
const hasReleasableApp = entries.some((entry) => {
|
|
2771
|
+
const projectJsonPath = (0, import_node_path6.join)(apps, entry, "project.json");
|
|
2772
|
+
return fileExists(projectJsonPath) && (readJson(projectJsonPath).tags ?? []).includes(GO_RELEASE_TAG);
|
|
2773
|
+
});
|
|
2774
|
+
const path = (0, import_node_path6.join)(workspaceRoot, GO_RELEASE_SCRIPT_PATH);
|
|
2775
|
+
if (!hasReleasableApp || fileExists(path) && (0, import_node_fs5.readFileSync)(path, "utf8") === GO_RELEASE_SCRIPT) {
|
|
2776
|
+
return false;
|
|
2777
|
+
}
|
|
2778
|
+
writeFileEnsured(path, GO_RELEASE_SCRIPT);
|
|
2779
|
+
return true;
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
// src/project-scaffolding/go.use-case.ts
|
|
2610
2783
|
function ensureGo(workspaceRoot) {
|
|
2611
2784
|
if (runShell("go", ["version"], workspaceRoot) !== 0) {
|
|
2612
2785
|
throw new Error("Go not found. Install Go 1.21+ first: https://go.dev/dl/");
|
|
@@ -2633,7 +2806,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
2633
2806
|
}
|
|
2634
2807
|
}
|
|
2635
2808
|
function ensureGoModule(workspaceRoot) {
|
|
2636
|
-
if (fileExists((0,
|
|
2809
|
+
if (fileExists((0, import_node_path7.join)(workspaceRoot, "go.mod"))) {
|
|
2637
2810
|
return;
|
|
2638
2811
|
}
|
|
2639
2812
|
logger.step("Bootstrapping the workspace Go module (single root go.mod)");
|
|
@@ -2642,7 +2815,7 @@ function ensureGoModule(workspaceRoot) {
|
|
|
2642
2815
|
}
|
|
2643
2816
|
function goModulePath(workspaceRoot) {
|
|
2644
2817
|
try {
|
|
2645
|
-
const contents = (0,
|
|
2818
|
+
const contents = (0, import_node_fs6.readFileSync)((0, import_node_path7.join)(workspaceRoot, "go.mod"), "utf8");
|
|
2646
2819
|
return /^module\s+(\S+)/m.exec(contents)?.[1];
|
|
2647
2820
|
} catch {
|
|
2648
2821
|
return void 0;
|
|
@@ -2704,16 +2877,16 @@ function goPackageAllTarget(tag, name) {
|
|
|
2704
2877
|
}
|
|
2705
2878
|
function addGoPlatformTargets(workspaceRoot) {
|
|
2706
2879
|
const changed = [];
|
|
2707
|
-
const apps = (0,
|
|
2880
|
+
const apps = (0, import_node_path7.join)(workspaceRoot, "apps");
|
|
2708
2881
|
if (!fileExists(apps)) {
|
|
2709
2882
|
return changed;
|
|
2710
2883
|
}
|
|
2711
|
-
for (const name of (0,
|
|
2712
|
-
const projectJsonPath = (0,
|
|
2884
|
+
for (const name of (0, import_node_fs6.readdirSync)(apps)) {
|
|
2885
|
+
const projectJsonPath = (0, import_node_path7.join)(apps, name, "project.json");
|
|
2713
2886
|
if (!fileExists(projectJsonPath)) {
|
|
2714
2887
|
continue;
|
|
2715
2888
|
}
|
|
2716
|
-
const project = JSON.parse((0,
|
|
2889
|
+
const project = JSON.parse((0, import_node_fs6.readFileSync)(projectJsonPath, "utf8"));
|
|
2717
2890
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
2718
2891
|
if (tag === void 0) {
|
|
2719
2892
|
continue;
|
|
@@ -2749,8 +2922,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
2749
2922
|
}
|
|
2750
2923
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
2751
2924
|
const { packageName, functionName, fileStem } = goLibraryIdentifiers(projectName);
|
|
2752
|
-
(0,
|
|
2753
|
-
(0,
|
|
2925
|
+
(0, import_node_fs6.rmSync)((0, import_node_path7.join)(projectRoot, `${projectName}.go`), { force: true });
|
|
2926
|
+
(0, import_node_fs6.rmSync)((0, import_node_path7.join)(projectRoot, `${projectName}_test.go`), { force: true });
|
|
2754
2927
|
const files = [
|
|
2755
2928
|
[
|
|
2756
2929
|
"doc.go",
|
|
@@ -2760,14 +2933,14 @@ package ${packageName}
|
|
|
2760
2933
|
`
|
|
2761
2934
|
],
|
|
2762
2935
|
[
|
|
2763
|
-
(0,
|
|
2936
|
+
(0, import_node_path7.join)(packageName, "doc.go"),
|
|
2764
2937
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
2765
2938
|
// the outcome it delivers, and add one package per further outcome.
|
|
2766
2939
|
package ${packageName}
|
|
2767
2940
|
`
|
|
2768
2941
|
],
|
|
2769
2942
|
[
|
|
2770
|
-
(0,
|
|
2943
|
+
(0, import_node_path7.join)(packageName, `${fileStem}_use_case.go`),
|
|
2771
2944
|
`package ${packageName}
|
|
2772
2945
|
|
|
2773
2946
|
// ${functionName} is the generator's sample behaviour, kept so the slice builds and tests.
|
|
@@ -2777,7 +2950,7 @@ func ${functionName}(name string) string {
|
|
|
2777
2950
|
`
|
|
2778
2951
|
],
|
|
2779
2952
|
[
|
|
2780
|
-
(0,
|
|
2953
|
+
(0, import_node_path7.join)(packageName, `${fileStem}_use_case_test.go`),
|
|
2781
2954
|
`package ${packageName}
|
|
2782
2955
|
|
|
2783
2956
|
import "testing"
|
|
@@ -2791,7 +2964,7 @@ func Test${functionName}(t *testing.T) {
|
|
|
2791
2964
|
]
|
|
2792
2965
|
];
|
|
2793
2966
|
for (const [relativePath, content] of files) {
|
|
2794
|
-
const path = (0,
|
|
2967
|
+
const path = (0, import_node_path7.join)(projectRoot, relativePath);
|
|
2795
2968
|
if (!fileExists(path)) {
|
|
2796
2969
|
writeFileEnsured(path, content);
|
|
2797
2970
|
}
|
|
@@ -2804,7 +2977,7 @@ function prepareGo(workspaceRoot) {
|
|
|
2804
2977
|
ensureNxGoPlugin(workspaceRoot);
|
|
2805
2978
|
ensureGoModule(workspaceRoot);
|
|
2806
2979
|
}
|
|
2807
|
-
function addGoApp(workspaceRoot, name) {
|
|
2980
|
+
function addGoApp(workspaceRoot, name, options = {}) {
|
|
2808
2981
|
prepareGo(workspaceRoot);
|
|
2809
2982
|
ensureAdmZip(workspaceRoot);
|
|
2810
2983
|
runNx(
|
|
@@ -2818,7 +2991,7 @@ function addGoApp(workspaceRoot, name) {
|
|
|
2818
2991
|
],
|
|
2819
2992
|
workspaceRoot
|
|
2820
2993
|
);
|
|
2821
|
-
addProjectJsonTargets((0,
|
|
2994
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
2822
2995
|
"build": goBuildTarget(name),
|
|
2823
2996
|
"test": goTestTarget(),
|
|
2824
2997
|
"lint": goLintTarget(),
|
|
@@ -2827,6 +3000,9 @@ function addGoApp(workspaceRoot, name) {
|
|
|
2827
3000
|
"package-all": goPackageAllTarget("go-app", name),
|
|
2828
3001
|
"start": goStartTarget(name)
|
|
2829
3002
|
});
|
|
3003
|
+
if (options.release === true) {
|
|
3004
|
+
makeGoAppReleasable(workspaceRoot, name);
|
|
3005
|
+
}
|
|
2830
3006
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
2831
3007
|
}
|
|
2832
3008
|
function addGoFunctionApp(workspaceRoot, name) {
|
|
@@ -2843,7 +3019,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
2843
3019
|
],
|
|
2844
3020
|
workspaceRoot
|
|
2845
3021
|
);
|
|
2846
|
-
addProjectJsonTargets((0,
|
|
3022
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
2847
3023
|
"build": goBuildTarget(name),
|
|
2848
3024
|
"test": goTestTarget(),
|
|
2849
3025
|
"lint": goLintTarget(),
|
|
@@ -2866,11 +3042,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
2866
3042
|
],
|
|
2867
3043
|
workspaceRoot
|
|
2868
3044
|
);
|
|
2869
|
-
addProjectJsonTargets((0,
|
|
3045
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
2870
3046
|
test: goTestTarget(),
|
|
2871
3047
|
lint: goLintTarget()
|
|
2872
3048
|
});
|
|
2873
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3049
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path7.join)(workspaceRoot, "packages", name), name);
|
|
2874
3050
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
2875
3051
|
const module2 = goModulePath(workspaceRoot);
|
|
2876
3052
|
if (module2) {
|
|
@@ -2890,11 +3066,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
2890
3066
|
],
|
|
2891
3067
|
workspaceRoot
|
|
2892
3068
|
);
|
|
2893
|
-
addProjectJsonTargets((0,
|
|
3069
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
2894
3070
|
test: goTestTarget(),
|
|
2895
3071
|
lint: goLintTarget()
|
|
2896
3072
|
});
|
|
2897
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3073
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path7.join)(workspaceRoot, "libs", name), name);
|
|
2898
3074
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
2899
3075
|
const module2 = goModulePath(workspaceRoot);
|
|
2900
3076
|
if (module2) {
|
|
@@ -2903,7 +3079,7 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
2903
3079
|
}
|
|
2904
3080
|
|
|
2905
3081
|
// src/project-scaffolding/node.use-case.ts
|
|
2906
|
-
var
|
|
3082
|
+
var import_node_path8 = require("path");
|
|
2907
3083
|
function ensurePlugin2(workspaceRoot, packageName) {
|
|
2908
3084
|
if (hasPlugin(workspaceRoot, packageName)) {
|
|
2909
3085
|
return;
|
|
@@ -2927,12 +3103,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
2927
3103
|
],
|
|
2928
3104
|
workspaceRoot
|
|
2929
3105
|
);
|
|
2930
|
-
const appRoot = (0,
|
|
3106
|
+
const appRoot = (0, import_node_path8.join)(workspaceRoot, "apps", name);
|
|
2931
3107
|
separateDeclarationOutput(appRoot);
|
|
2932
3108
|
repairAssetMapping(appRoot, name);
|
|
2933
3109
|
}
|
|
2934
3110
|
function separateDeclarationOutput(appRoot) {
|
|
2935
|
-
const tsconfigPath = (0,
|
|
3111
|
+
const tsconfigPath = (0, import_node_path8.join)(appRoot, "tsconfig.app.json");
|
|
2936
3112
|
if (!fileExists(tsconfigPath)) {
|
|
2937
3113
|
return;
|
|
2938
3114
|
}
|
|
@@ -2954,7 +3130,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
2954
3130
|
);
|
|
2955
3131
|
}
|
|
2956
3132
|
function repairAssetMapping(appRoot, name) {
|
|
2957
|
-
const manifestPath = (0,
|
|
3133
|
+
const manifestPath = (0, import_node_path8.join)(appRoot, "package.json");
|
|
2958
3134
|
if (!fileExists(manifestPath)) {
|
|
2959
3135
|
return;
|
|
2960
3136
|
}
|
|
@@ -2981,7 +3157,7 @@ function nodeAppPackageTarget(name) {
|
|
|
2981
3157
|
function addNodeApp(workspaceRoot, name, stack, framework = "none") {
|
|
2982
3158
|
runNodeApp(workspaceRoot, name, stack, framework);
|
|
2983
3159
|
ensureAdmZip(workspaceRoot);
|
|
2984
|
-
addNxTargets((0,
|
|
3160
|
+
addNxTargets((0, import_node_path8.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
2985
3161
|
package: nodeAppPackageTarget(name)
|
|
2986
3162
|
});
|
|
2987
3163
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -3037,10 +3213,10 @@ describe('buildGreeting', () => {
|
|
|
3037
3213
|
})
|
|
3038
3214
|
`;
|
|
3039
3215
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
3040
|
-
const manifestPath = (0,
|
|
3216
|
+
const manifestPath = (0, import_node_path8.join)(nodeFunctionAppRoot, "package.json");
|
|
3041
3217
|
const manifest = readJson(manifestPath);
|
|
3042
3218
|
const azureFunctionsVersion = readJson(
|
|
3043
|
-
(0,
|
|
3219
|
+
(0, import_node_path8.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
3044
3220
|
).version;
|
|
3045
3221
|
const dependencies = manifest.dependencies ?? {};
|
|
3046
3222
|
writeFileEnsured(
|
|
@@ -3083,21 +3259,21 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
3083
3259
|
function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
3084
3260
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
3085
3261
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
3086
|
-
const nodeFunctionAppRoot = (0,
|
|
3087
|
-
writeFileEnsured((0,
|
|
3088
|
-
writeFileEnsured((0,
|
|
3262
|
+
const nodeFunctionAppRoot = (0, import_node_path8.join)(workspaceRoot, "apps", name);
|
|
3263
|
+
writeFileEnsured((0, import_node_path8.join)(nodeFunctionAppRoot, "src/main.ts"), NODE_FUNCTION_APP_MAIN);
|
|
3264
|
+
writeFileEnsured((0, import_node_path8.join)(nodeFunctionAppRoot, "src/functions/hello.ts"), NODE_FUNCTION_APP_HELLO);
|
|
3089
3265
|
writeFileEnsured(
|
|
3090
|
-
(0,
|
|
3266
|
+
(0, import_node_path8.join)(nodeFunctionAppRoot, "src/functions/greeting.ts"),
|
|
3091
3267
|
NODE_FUNCTION_APP_GREETING
|
|
3092
3268
|
);
|
|
3093
3269
|
writeFileEnsured(
|
|
3094
|
-
(0,
|
|
3270
|
+
(0, import_node_path8.join)(nodeFunctionAppRoot, "src/functions/greeting.spec.ts"),
|
|
3095
3271
|
NODE_FUNCTION_APP_GREETING_SPEC
|
|
3096
3272
|
);
|
|
3097
|
-
writeFileEnsured((0,
|
|
3273
|
+
writeFileEnsured((0, import_node_path8.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
3098
3274
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
3099
3275
|
ensureAdmZip(workspaceRoot);
|
|
3100
|
-
addNxTargets((0,
|
|
3276
|
+
addNxTargets((0, import_node_path8.join)(nodeFunctionAppRoot, "package.json"), {
|
|
3101
3277
|
package: nodeFunctionAppPackageTarget(name),
|
|
3102
3278
|
prune: nodeFunctionAppPruneTarget(name),
|
|
3103
3279
|
start: nodeFunctionAppStartTarget(name)
|
|
@@ -3107,11 +3283,11 @@ function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
|
3107
3283
|
}
|
|
3108
3284
|
|
|
3109
3285
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
3110
|
-
var
|
|
3286
|
+
var import_node_path12 = require("path");
|
|
3111
3287
|
|
|
3112
3288
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
3113
|
-
var
|
|
3114
|
-
var
|
|
3289
|
+
var import_node_fs7 = require("fs");
|
|
3290
|
+
var import_node_path9 = require("path");
|
|
3115
3291
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
3116
3292
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
3117
3293
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -3134,14 +3310,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
3134
3310
|
}
|
|
3135
3311
|
function repairPublishableManifests(workspaceRoot) {
|
|
3136
3312
|
const changed = [];
|
|
3137
|
-
const manifests = (0,
|
|
3313
|
+
const manifests = (0, import_node_fs7.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
3138
3314
|
cwd: workspaceRoot
|
|
3139
3315
|
});
|
|
3140
3316
|
for (const relativePath of manifests) {
|
|
3141
|
-
const manifestPath = (0,
|
|
3142
|
-
const before = (0,
|
|
3317
|
+
const manifestPath = (0, import_node_path9.join)(workspaceRoot, relativePath);
|
|
3318
|
+
const before = (0, import_node_fs7.readFileSync)(manifestPath, "utf8");
|
|
3143
3319
|
repairPublishableManifest(manifestPath);
|
|
3144
|
-
const after = (0,
|
|
3320
|
+
const after = (0, import_node_fs7.readFileSync)(manifestPath, "utf8");
|
|
3145
3321
|
if (after !== before) {
|
|
3146
3322
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
3147
3323
|
}
|
|
@@ -3150,8 +3326,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
3150
3326
|
}
|
|
3151
3327
|
|
|
3152
3328
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
3153
|
-
var
|
|
3154
|
-
var
|
|
3329
|
+
var import_node_fs8 = require("fs");
|
|
3330
|
+
var import_node_path10 = require("path");
|
|
3155
3331
|
|
|
3156
3332
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
3157
3333
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -3353,12 +3529,12 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
3353
3529
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
3354
3530
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
3355
3531
|
const changed = [];
|
|
3356
|
-
const configs = (0,
|
|
3532
|
+
const configs = (0, import_node_fs8.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
3357
3533
|
cwd: workspaceRoot
|
|
3358
3534
|
});
|
|
3359
3535
|
for (const relativePath of configs) {
|
|
3360
|
-
const configPath = (0,
|
|
3361
|
-
const before = (0,
|
|
3536
|
+
const configPath = (0, import_node_path10.join)(workspaceRoot, relativePath);
|
|
3537
|
+
const before = (0, import_node_fs8.readFileSync)(configPath, "utf8");
|
|
3362
3538
|
const after = withRollupSourceMaps(before);
|
|
3363
3539
|
if (after !== before) {
|
|
3364
3540
|
writeFileEnsured(configPath, after);
|
|
@@ -3369,12 +3545,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
3369
3545
|
}
|
|
3370
3546
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
3371
3547
|
const changed = [];
|
|
3372
|
-
const configs = (0,
|
|
3548
|
+
const configs = (0, import_node_fs8.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
3373
3549
|
cwd: workspaceRoot
|
|
3374
3550
|
});
|
|
3375
3551
|
for (const relativePath of configs) {
|
|
3376
|
-
const configPath = (0,
|
|
3377
|
-
const before = (0,
|
|
3552
|
+
const configPath = (0, import_node_path10.join)(workspaceRoot, relativePath);
|
|
3553
|
+
const before = (0, import_node_fs8.readFileSync)(configPath, "utf8");
|
|
3378
3554
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
3379
3555
|
if (after !== before) {
|
|
3380
3556
|
writeFileEnsured(configPath, after);
|
|
@@ -3384,11 +3560,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
3384
3560
|
return changed;
|
|
3385
3561
|
}
|
|
3386
3562
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
3387
|
-
const configPath = (0,
|
|
3563
|
+
const configPath = (0, import_node_path10.join)(projectRoot, "rollup.config.cjs");
|
|
3388
3564
|
if (!fileExists(configPath)) {
|
|
3389
3565
|
return;
|
|
3390
3566
|
}
|
|
3391
|
-
const config = (0,
|
|
3567
|
+
const config = (0, import_node_fs8.readFileSync)(configPath, "utf8");
|
|
3392
3568
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
3393
3569
|
return;
|
|
3394
3570
|
}
|
|
@@ -3397,10 +3573,10 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
3397
3573
|
}
|
|
3398
3574
|
|
|
3399
3575
|
// src/rollup-library/rollup-config.repository.ts
|
|
3400
|
-
var
|
|
3401
|
-
var
|
|
3576
|
+
var import_node_fs9 = require("fs");
|
|
3577
|
+
var import_node_path11 = require("path");
|
|
3402
3578
|
function resolveRequireTarget(fromDir, specifier) {
|
|
3403
|
-
const base = (0,
|
|
3579
|
+
const base = (0, import_node_path11.join)(fromDir, specifier);
|
|
3404
3580
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
3405
3581
|
}
|
|
3406
3582
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -3410,7 +3586,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
3410
3586
|
visited.add(configPath);
|
|
3411
3587
|
let text;
|
|
3412
3588
|
try {
|
|
3413
|
-
text = (0,
|
|
3589
|
+
text = (0, import_node_fs9.readFileSync)(configPath, "utf8");
|
|
3414
3590
|
} catch {
|
|
3415
3591
|
return "";
|
|
3416
3592
|
}
|
|
@@ -3418,15 +3594,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
3418
3594
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
3419
3595
|
(match) => match[2]
|
|
3420
3596
|
);
|
|
3421
|
-
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0,
|
|
3597
|
+
const requiredText = specifiers.map((specifier) => resolveRequireTarget((0, import_node_path11.dirname)(configPath), specifier)).filter((target) => target !== void 0).map((target) => resolveRollupConfigText(target, visited));
|
|
3422
3598
|
return [text, ...requiredText].join("\n");
|
|
3423
3599
|
}
|
|
3424
3600
|
|
|
3425
3601
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
3426
3602
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
3427
3603
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
3428
|
-
const projectRoot = (0,
|
|
3429
|
-
const manifestPath = (0,
|
|
3604
|
+
const projectRoot = (0, import_node_path12.join)(workspaceRoot, "packages", name);
|
|
3605
|
+
const manifestPath = (0, import_node_path12.join)(projectRoot, "package.json");
|
|
3430
3606
|
runGeneratorAndRepair(
|
|
3431
3607
|
workspaceRoot,
|
|
3432
3608
|
[
|
|
@@ -3455,8 +3631,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
3455
3631
|
}
|
|
3456
3632
|
|
|
3457
3633
|
// src/project-scaffolding/python.use-case.ts
|
|
3458
|
-
var
|
|
3459
|
-
var
|
|
3634
|
+
var import_node_fs10 = require("fs");
|
|
3635
|
+
var import_node_path13 = require("path");
|
|
3460
3636
|
function ensurePython(workspaceRoot) {
|
|
3461
3637
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
3462
3638
|
if (!hasPython) {
|
|
@@ -3479,7 +3655,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
3479
3655
|
registerPythonGraphPlugin(workspaceRoot);
|
|
3480
3656
|
}
|
|
3481
3657
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
3482
|
-
const nxJsonPath = (0,
|
|
3658
|
+
const nxJsonPath = (0, import_node_path13.join)(workspaceRoot, "nx.json");
|
|
3483
3659
|
if (!fileExists(nxJsonPath)) {
|
|
3484
3660
|
return;
|
|
3485
3661
|
}
|
|
@@ -3502,7 +3678,7 @@ pytest
|
|
|
3502
3678
|
pip-audit
|
|
3503
3679
|
`;
|
|
3504
3680
|
function ensureRequirementsDev(workspaceRoot) {
|
|
3505
|
-
const requirementsDevPath = (0,
|
|
3681
|
+
const requirementsDevPath = (0, import_node_path13.join)(workspaceRoot, "requirements-dev.txt");
|
|
3506
3682
|
if (!fileExists(requirementsDevPath)) {
|
|
3507
3683
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
3508
3684
|
}
|
|
@@ -3562,8 +3738,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
3562
3738
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
3563
3739
|
workspaceRoot
|
|
3564
3740
|
);
|
|
3565
|
-
writeFileEnsured((0,
|
|
3566
|
-
addProjectJsonTargets((0,
|
|
3741
|
+
writeFileEnsured((0, import_node_path13.join)(workspaceRoot, "apps", name, "main.py"), pythonAppMain(name));
|
|
3742
|
+
addProjectJsonTargets((0, import_node_path13.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3567
3743
|
package: pythonAppPackageTarget(name),
|
|
3568
3744
|
start: pythonAppStartTarget(name)
|
|
3569
3745
|
});
|
|
@@ -3585,7 +3761,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
3585
3761
|
workspaceRoot
|
|
3586
3762
|
);
|
|
3587
3763
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
3588
|
-
addProjectJsonTargets((0,
|
|
3764
|
+
addProjectJsonTargets((0, import_node_path13.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3589
3765
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
3590
3766
|
start: pythonFunctionAppStartTarget(name)
|
|
3591
3767
|
});
|
|
@@ -3626,7 +3802,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
3626
3802
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
3627
3803
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
3628
3804
|
return PYTHON_PROJECT_DIRS.find(
|
|
3629
|
-
(directory) => fileExists((0,
|
|
3805
|
+
(directory) => fileExists((0, import_node_path13.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
3630
3806
|
);
|
|
3631
3807
|
}
|
|
3632
3808
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -3665,7 +3841,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
3665
3841
|
`No Python project named '${consumer}' with a pyproject.toml found (checked apps/, python-packages/, libs/). A Python function app has no pyproject.toml \u2014 there is nothing to vendor into.`
|
|
3666
3842
|
);
|
|
3667
3843
|
}
|
|
3668
|
-
if (!fileExists((0,
|
|
3844
|
+
if (!fileExists((0, import_node_path13.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
3669
3845
|
throw new Error(
|
|
3670
3846
|
`No internal Python library named '${lib}' found at libs/${lib}/pyproject.toml. Only an internal library (added via 'mnci add python-internal-lib') can be vendored.`
|
|
3671
3847
|
);
|
|
@@ -3673,8 +3849,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
3673
3849
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
3674
3850
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
3675
3851
|
}
|
|
3676
|
-
const pyprojectPath = (0,
|
|
3677
|
-
const pyprojectToml = (0,
|
|
3852
|
+
const pyprojectPath = (0, import_node_path13.join)(workspaceRoot, consumerDirectory, consumer, "pyproject.toml");
|
|
3853
|
+
const pyprojectToml = (0, import_node_fs10.readFileSync)(pyprojectPath, "utf8");
|
|
3678
3854
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
3679
3855
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
3680
3856
|
return;
|
|
@@ -3686,8 +3862,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
3686
3862
|
}
|
|
3687
3863
|
|
|
3688
3864
|
// src/project-scaffolding/react-app.use-case.ts
|
|
3689
|
-
var
|
|
3690
|
-
var
|
|
3865
|
+
var import_node_fs11 = require("fs");
|
|
3866
|
+
var import_node_path14 = require("path");
|
|
3691
3867
|
var REACT_ENVIRONMENTS = ["dev", "uat", "prod"];
|
|
3692
3868
|
function reactEnvironmentFile(environment) {
|
|
3693
3869
|
return `# Vite compiles VITE_-prefixed vars into the '${environment}' bundle at build time.
|
|
@@ -3724,12 +3900,12 @@ function reactAppTargets(name) {
|
|
|
3724
3900
|
return targets;
|
|
3725
3901
|
}
|
|
3726
3902
|
function allowEnvFiles(workspaceRoot) {
|
|
3727
|
-
const gitignorePath = (0,
|
|
3903
|
+
const gitignorePath = (0, import_node_path14.join)(workspaceRoot, ".gitignore");
|
|
3728
3904
|
if (!fileExists(gitignorePath)) {
|
|
3729
3905
|
return;
|
|
3730
3906
|
}
|
|
3731
3907
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
3732
|
-
const current = (0,
|
|
3908
|
+
const current = (0, import_node_fs11.readFileSync)(gitignorePath, "utf8");
|
|
3733
3909
|
if (current.includes(marker)) {
|
|
3734
3910
|
return;
|
|
3735
3911
|
}
|
|
@@ -3756,24 +3932,24 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
3756
3932
|
workspaceRoot
|
|
3757
3933
|
);
|
|
3758
3934
|
ensureAdmZip(workspaceRoot);
|
|
3759
|
-
const reactAppRoot = (0,
|
|
3935
|
+
const reactAppRoot = (0, import_node_path14.join)(workspaceRoot, "apps", name);
|
|
3760
3936
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
3761
|
-
writeFileEnsured((0,
|
|
3937
|
+
writeFileEnsured((0, import_node_path14.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
3762
3938
|
}
|
|
3763
3939
|
allowEnvFiles(workspaceRoot);
|
|
3764
|
-
addNxTargets((0,
|
|
3940
|
+
addNxTargets((0, import_node_path14.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
3765
3941
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
3766
3942
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
3767
3943
|
}
|
|
3768
3944
|
|
|
3769
3945
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
3770
|
-
var
|
|
3946
|
+
var import_node_path15 = require("path");
|
|
3771
3947
|
var REACT_LIB_BUNDLER = "rollup";
|
|
3772
3948
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
3773
3949
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
3774
3950
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
3775
|
-
const projectRoot = (0,
|
|
3776
|
-
const publishableManifest = (0,
|
|
3951
|
+
const projectRoot = (0, import_node_path15.join)(workspaceRoot, "packages", name);
|
|
3952
|
+
const publishableManifest = (0, import_node_path15.join)(projectRoot, "package.json");
|
|
3777
3953
|
runGeneratorAndRepair(
|
|
3778
3954
|
workspaceRoot,
|
|
3779
3955
|
[
|
|
@@ -3802,8 +3978,8 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
3802
3978
|
}
|
|
3803
3979
|
function addReactInternalLib(workspaceRoot, name, stack) {
|
|
3804
3980
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
3805
|
-
const projectRoot = (0,
|
|
3806
|
-
const privateManifest = (0,
|
|
3981
|
+
const projectRoot = (0, import_node_path15.join)(workspaceRoot, "libs", name);
|
|
3982
|
+
const privateManifest = (0, import_node_path15.join)(projectRoot, "package.json");
|
|
3807
3983
|
runGeneratorAndRepair(
|
|
3808
3984
|
workspaceRoot,
|
|
3809
3985
|
[
|
|
@@ -3829,8 +4005,8 @@ function addReactInternalLib(workspaceRoot, name, stack) {
|
|
|
3829
4005
|
}
|
|
3830
4006
|
|
|
3831
4007
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
3832
|
-
var
|
|
3833
|
-
var
|
|
4008
|
+
var import_node_fs12 = require("fs");
|
|
4009
|
+
var import_node_path16 = require("path");
|
|
3834
4010
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
3835
4011
|
var VSCODE_SIDECAR_TARGETS = {
|
|
3836
4012
|
"win32-x64": "windows-amd64",
|
|
@@ -4014,8 +4190,8 @@ export const window = {
|
|
|
4014
4190
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
4015
4191
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
4016
4192
|
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}\` },`];
|
|
4017
|
-
const path = (0,
|
|
4018
|
-
const content = fileExists(path) ? (0,
|
|
4193
|
+
const path = (0, import_node_path16.join)(projectRoot, file);
|
|
4194
|
+
const content = fileExists(path) ? (0, import_node_fs12.readFileSync)(path, "utf8") : "";
|
|
4019
4195
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
4020
4196
|
if (line === void 0) {
|
|
4021
4197
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -4035,11 +4211,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
4035
4211
|
}
|
|
4036
4212
|
}
|
|
4037
4213
|
function defaultPublisher(workspaceRoot) {
|
|
4038
|
-
const { name } = readJson((0,
|
|
4214
|
+
const { name } = readJson((0, import_node_path16.join)(workspaceRoot, "package.json"));
|
|
4039
4215
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
4040
4216
|
}
|
|
4041
4217
|
function reshapeManifest(projectRoot, name, publisher, typesVersion) {
|
|
4042
|
-
const manifestPath = (0,
|
|
4218
|
+
const manifestPath = (0, import_node_path16.join)(projectRoot, "package.json");
|
|
4043
4219
|
const manifest = readJson(manifestPath);
|
|
4044
4220
|
const { nx = {}, ...rest } = manifest;
|
|
4045
4221
|
const targets = { ...nx.targets };
|
|
@@ -4103,11 +4279,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
4103
4279
|
};
|
|
4104
4280
|
}
|
|
4105
4281
|
function addDebugLaunch(workspaceRoot, name) {
|
|
4106
|
-
const file = (0,
|
|
4282
|
+
const file = (0, import_node_fs12.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
4107
4283
|
if (file === void 0) {
|
|
4108
4284
|
return;
|
|
4109
4285
|
}
|
|
4110
|
-
const path = (0,
|
|
4286
|
+
const path = (0, import_node_path16.join)(workspaceRoot, file);
|
|
4111
4287
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
4112
4288
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
4113
4289
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -4140,39 +4316,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
4140
4316
|
);
|
|
4141
4317
|
}
|
|
4142
4318
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
4143
|
-
const apps = (0,
|
|
4319
|
+
const apps = (0, import_node_path16.join)(workspaceRoot, "apps");
|
|
4144
4320
|
let entries;
|
|
4145
4321
|
try {
|
|
4146
|
-
entries = (0,
|
|
4322
|
+
entries = (0, import_node_fs12.readdirSync)(apps);
|
|
4147
4323
|
} catch {
|
|
4148
4324
|
return false;
|
|
4149
4325
|
}
|
|
4150
4326
|
const hasExtension = entries.some((entry) => {
|
|
4151
|
-
const manifestPath = (0,
|
|
4327
|
+
const manifestPath = (0, import_node_path16.join)(apps, entry, "package.json");
|
|
4152
4328
|
if (!fileExists(manifestPath)) {
|
|
4153
4329
|
return false;
|
|
4154
4330
|
}
|
|
4155
4331
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
4156
4332
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
4157
4333
|
});
|
|
4158
|
-
const path = (0,
|
|
4159
|
-
if (!hasExtension || fileExists(path) && (0,
|
|
4334
|
+
const path = (0, import_node_path16.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH);
|
|
4335
|
+
if (!hasExtension || fileExists(path) && (0, import_node_fs12.readFileSync)(path, "utf8") === VSCODE_EXTENSION_SCRIPT) {
|
|
4160
4336
|
return false;
|
|
4161
4337
|
}
|
|
4162
4338
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
4163
4339
|
return true;
|
|
4164
4340
|
}
|
|
4165
4341
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
4166
|
-
const apps = (0,
|
|
4342
|
+
const apps = (0, import_node_path16.join)(workspaceRoot, "apps");
|
|
4167
4343
|
let entries;
|
|
4168
4344
|
try {
|
|
4169
|
-
entries = (0,
|
|
4345
|
+
entries = (0, import_node_fs12.readdirSync)(apps);
|
|
4170
4346
|
} catch {
|
|
4171
4347
|
return [];
|
|
4172
4348
|
}
|
|
4173
4349
|
const updated = [];
|
|
4174
4350
|
for (const entry of entries) {
|
|
4175
|
-
const manifestPath = (0,
|
|
4351
|
+
const manifestPath = (0, import_node_path16.join)(apps, entry, "package.json");
|
|
4176
4352
|
if (!fileExists(manifestPath)) {
|
|
4177
4353
|
continue;
|
|
4178
4354
|
}
|
|
@@ -4192,23 +4368,23 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
4192
4368
|
}
|
|
4193
4369
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
4194
4370
|
const { sidecar } = options;
|
|
4195
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
4371
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path16.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
4196
4372
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
4197
4373
|
}
|
|
4198
4374
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4199
4375
|
ensureVscodeToolchain(workspaceRoot);
|
|
4200
|
-
const projectRoot = (0,
|
|
4201
|
-
const typesVersion = readJson((0,
|
|
4376
|
+
const projectRoot = (0, import_node_path16.join)(workspaceRoot, "apps", name);
|
|
4377
|
+
const typesVersion = readJson((0, import_node_path16.join)(workspaceRoot, "node_modules/@types/vscode/package.json")).version;
|
|
4202
4378
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot), typesVersion);
|
|
4203
|
-
addVscodeTypes((0,
|
|
4204
|
-
addVscodeTypes((0,
|
|
4205
|
-
writeFileEnsured((0,
|
|
4206
|
-
writeFileEnsured((0,
|
|
4207
|
-
writeFileEnsured((0,
|
|
4379
|
+
addVscodeTypes((0, import_node_path16.join)(projectRoot, "tsconfig.app.json"));
|
|
4380
|
+
addVscodeTypes((0, import_node_path16.join)(projectRoot, "tsconfig.spec.json"));
|
|
4381
|
+
writeFileEnsured((0, import_node_path16.join)(projectRoot, "src/main.ts"), vscodeExtensionMain(name));
|
|
4382
|
+
writeFileEnsured((0, import_node_path16.join)(projectRoot, "src/main.spec.ts"), vscodeExtensionMainSpec(name));
|
|
4383
|
+
writeFileEnsured((0, import_node_path16.join)(projectRoot, VSCODE_STUB_PATH), VSCODE_STUB);
|
|
4208
4384
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
4209
|
-
writeFileEnsured((0,
|
|
4210
|
-
writeFileEnsured((0,
|
|
4211
|
-
addNxTargets((0,
|
|
4385
|
+
writeFileEnsured((0, import_node_path16.join)(projectRoot, ".vscodeignore"), VSCODE_IGNORE);
|
|
4386
|
+
writeFileEnsured((0, import_node_path16.join)(workspaceRoot, VSCODE_EXTENSION_SCRIPT_PATH), VSCODE_EXTENSION_SCRIPT);
|
|
4387
|
+
addNxTargets((0, import_node_path16.join)(projectRoot, "package.json"), {
|
|
4212
4388
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
4213
4389
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
4214
4390
|
});
|
|
@@ -4219,11 +4395,11 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
4219
4395
|
}
|
|
4220
4396
|
|
|
4221
4397
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
4222
|
-
var
|
|
4398
|
+
var import_node_path18 = require("path");
|
|
4223
4399
|
|
|
4224
4400
|
// src/dependency-management/manifest.repository.ts
|
|
4225
|
-
var
|
|
4226
|
-
var
|
|
4401
|
+
var import_node_fs13 = require("fs");
|
|
4402
|
+
var import_node_path17 = require("path");
|
|
4227
4403
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
4228
4404
|
var ROOT_LABEL = "(root)";
|
|
4229
4405
|
var MANIFEST_GLOBS = {
|
|
@@ -4256,23 +4432,23 @@ function projectOf(manifestRelativePath) {
|
|
|
4256
4432
|
}
|
|
4257
4433
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
4258
4434
|
if (ecosystem === "go") {
|
|
4259
|
-
return fileExists((0,
|
|
4435
|
+
return fileExists((0, import_node_path17.join)(workspaceRoot, "go.mod"));
|
|
4260
4436
|
}
|
|
4261
4437
|
if (ecosystem === "nuget") {
|
|
4262
|
-
return (0,
|
|
4438
|
+
return (0, import_node_fs13.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
4263
4439
|
}
|
|
4264
4440
|
const rootMarker = {
|
|
4265
4441
|
npm: "package.json",
|
|
4266
4442
|
pip: "requirements-dev.txt",
|
|
4267
4443
|
pub: "pubspec.yaml"
|
|
4268
4444
|
};
|
|
4269
|
-
return fileExists((0,
|
|
4445
|
+
return fileExists((0, import_node_path17.join)(workspaceRoot, rootMarker[ecosystem])) || (0, import_node_fs13.globSync)(MANIFEST_GLOBS[ecosystem], { cwd: workspaceRoot }).length > 0;
|
|
4270
4446
|
}
|
|
4271
4447
|
function collectNpm(workspaceRoot) {
|
|
4272
4448
|
const sites = [];
|
|
4273
|
-
const relativePaths = ["package.json", ...(0,
|
|
4449
|
+
const relativePaths = ["package.json", ...(0, import_node_fs13.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
4274
4450
|
for (const relativePath of relativePaths) {
|
|
4275
|
-
const manifestPath = (0,
|
|
4451
|
+
const manifestPath = (0, import_node_path17.join)(workspaceRoot, relativePath);
|
|
4276
4452
|
try {
|
|
4277
4453
|
const manifest = readJson(manifestPath);
|
|
4278
4454
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -4333,17 +4509,17 @@ function collectPip(workspaceRoot) {
|
|
|
4333
4509
|
name: parsed.name,
|
|
4334
4510
|
ecosystem: "pip",
|
|
4335
4511
|
project: projectOf(relativePath),
|
|
4336
|
-
manifestPath: (0,
|
|
4512
|
+
manifestPath: (0, import_node_path17.join)(workspaceRoot, relativePath),
|
|
4337
4513
|
section,
|
|
4338
4514
|
spec: parsed.spec,
|
|
4339
4515
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
4340
4516
|
});
|
|
4341
4517
|
};
|
|
4342
|
-
const pyprojectPaths = (0,
|
|
4518
|
+
const pyprojectPaths = (0, import_node_fs13.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
4343
4519
|
for (const relativePath of pyprojectPaths) {
|
|
4344
4520
|
let content;
|
|
4345
4521
|
try {
|
|
4346
|
-
content = (0,
|
|
4522
|
+
content = (0, import_node_fs13.readFileSync)((0, import_node_path17.join)(workspaceRoot, relativePath), "utf8");
|
|
4347
4523
|
} catch {
|
|
4348
4524
|
continue;
|
|
4349
4525
|
}
|
|
@@ -4354,14 +4530,14 @@ function collectPip(workspaceRoot) {
|
|
|
4354
4530
|
}
|
|
4355
4531
|
const requirementsPaths = [
|
|
4356
4532
|
"requirements-dev.txt",
|
|
4357
|
-
...(0,
|
|
4533
|
+
...(0, import_node_fs13.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
4358
4534
|
];
|
|
4359
4535
|
for (const relativePath of requirementsPaths) {
|
|
4360
|
-
if (!fileExists((0,
|
|
4536
|
+
if (!fileExists((0, import_node_path17.join)(workspaceRoot, relativePath))) {
|
|
4361
4537
|
continue;
|
|
4362
4538
|
}
|
|
4363
4539
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
4364
|
-
const lines = (0,
|
|
4540
|
+
const lines = (0, import_node_fs13.readFileSync)((0, import_node_path17.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
4365
4541
|
for (const line of lines) {
|
|
4366
4542
|
push(relativePath, section, line);
|
|
4367
4543
|
}
|
|
@@ -4399,11 +4575,11 @@ function pyprojectDependencies(content) {
|
|
|
4399
4575
|
}
|
|
4400
4576
|
function collectPub(workspaceRoot) {
|
|
4401
4577
|
const sites = [];
|
|
4402
|
-
const pubspecPaths = (0,
|
|
4578
|
+
const pubspecPaths = (0, import_node_fs13.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
4403
4579
|
for (const relativePath of pubspecPaths) {
|
|
4404
4580
|
let content;
|
|
4405
4581
|
try {
|
|
4406
|
-
content = (0,
|
|
4582
|
+
content = (0, import_node_fs13.readFileSync)((0, import_node_path17.join)(workspaceRoot, relativePath), "utf8");
|
|
4407
4583
|
} catch {
|
|
4408
4584
|
continue;
|
|
4409
4585
|
}
|
|
@@ -4413,7 +4589,7 @@ function collectPub(workspaceRoot) {
|
|
|
4413
4589
|
name: entry.name,
|
|
4414
4590
|
ecosystem: "pub",
|
|
4415
4591
|
project: projectOf(relativePath),
|
|
4416
|
-
manifestPath: (0,
|
|
4592
|
+
manifestPath: (0, import_node_path17.join)(workspaceRoot, relativePath),
|
|
4417
4593
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
4418
4594
|
spec: entry.spec,
|
|
4419
4595
|
rewritable: entry.spec !== ""
|
|
@@ -4463,11 +4639,11 @@ function stripQuotes(value) {
|
|
|
4463
4639
|
}
|
|
4464
4640
|
function collectNuget(workspaceRoot) {
|
|
4465
4641
|
const sites = [];
|
|
4466
|
-
const csprojPaths = (0,
|
|
4642
|
+
const csprojPaths = (0, import_node_fs13.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
4467
4643
|
for (const relativePath of csprojPaths) {
|
|
4468
4644
|
let content;
|
|
4469
4645
|
try {
|
|
4470
|
-
content = (0,
|
|
4646
|
+
content = (0, import_node_fs13.readFileSync)((0, import_node_path17.join)(workspaceRoot, relativePath), "utf8");
|
|
4471
4647
|
} catch {
|
|
4472
4648
|
continue;
|
|
4473
4649
|
}
|
|
@@ -4476,7 +4652,7 @@ function collectNuget(workspaceRoot) {
|
|
|
4476
4652
|
name: entry.name,
|
|
4477
4653
|
ecosystem: "nuget",
|
|
4478
4654
|
project: projectOf(relativePath),
|
|
4479
|
-
manifestPath: (0,
|
|
4655
|
+
manifestPath: (0, import_node_path17.join)(workspaceRoot, relativePath),
|
|
4480
4656
|
section: "dep",
|
|
4481
4657
|
spec: entry.spec,
|
|
4482
4658
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -4501,13 +4677,13 @@ function csprojPackageReferences(content) {
|
|
|
4501
4677
|
return entries;
|
|
4502
4678
|
}
|
|
4503
4679
|
function collectGo(workspaceRoot) {
|
|
4504
|
-
const manifestPath = (0,
|
|
4680
|
+
const manifestPath = (0, import_node_path17.join)(workspaceRoot, "go.mod");
|
|
4505
4681
|
if (!fileExists(manifestPath)) {
|
|
4506
4682
|
return [];
|
|
4507
4683
|
}
|
|
4508
4684
|
let content;
|
|
4509
4685
|
try {
|
|
4510
|
-
content = (0,
|
|
4686
|
+
content = (0, import_node_fs13.readFileSync)(manifestPath, "utf8");
|
|
4511
4687
|
} catch {
|
|
4512
4688
|
return [];
|
|
4513
4689
|
}
|
|
@@ -4564,7 +4740,7 @@ function rewriteSpec(site, spec) {
|
|
|
4564
4740
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
4565
4741
|
return true;
|
|
4566
4742
|
}
|
|
4567
|
-
const before = (0,
|
|
4743
|
+
const before = (0, import_node_fs13.readFileSync)(site.manifestPath, "utf8");
|
|
4568
4744
|
const after = (() => {
|
|
4569
4745
|
switch (site.ecosystem) {
|
|
4570
4746
|
case "pip": {
|
|
@@ -4620,13 +4796,13 @@ function escapeForRegex(value) {
|
|
|
4620
4796
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
4621
4797
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
4622
4798
|
return ["apps", "libs", "packages"].some(
|
|
4623
|
-
(directory) => fileExists((0,
|
|
4799
|
+
(directory) => fileExists((0, import_node_path17.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
4624
4800
|
);
|
|
4625
4801
|
}
|
|
4626
4802
|
function isAliasedInstall(workspaceRoot, name) {
|
|
4627
4803
|
try {
|
|
4628
4804
|
const installed = readJson(
|
|
4629
|
-
(0,
|
|
4805
|
+
(0, import_node_path17.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
4630
4806
|
);
|
|
4631
4807
|
return installed.name !== void 0 && installed.name !== name;
|
|
4632
4808
|
} catch {
|
|
@@ -4637,14 +4813,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
4637
4813
|
if (ecosystem === "npm") {
|
|
4638
4814
|
try {
|
|
4639
4815
|
return readJson(
|
|
4640
|
-
(0,
|
|
4816
|
+
(0, import_node_path17.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
4641
4817
|
).version;
|
|
4642
4818
|
} catch {
|
|
4643
4819
|
return void 0;
|
|
4644
4820
|
}
|
|
4645
4821
|
}
|
|
4646
4822
|
if (ecosystem === "pub") {
|
|
4647
|
-
const lockPath = (0,
|
|
4823
|
+
const lockPath = (0, import_node_path17.join)(workspaceRoot, "pubspec.lock");
|
|
4648
4824
|
if (!fileExists(lockPath)) {
|
|
4649
4825
|
return void 0;
|
|
4650
4826
|
}
|
|
@@ -4652,7 +4828,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
4652
4828
|
const match = new RegExp(
|
|
4653
4829
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
4654
4830
|
"m"
|
|
4655
|
-
).exec((0,
|
|
4831
|
+
).exec((0, import_node_fs13.readFileSync)(lockPath, "utf8"));
|
|
4656
4832
|
return match?.[1];
|
|
4657
4833
|
} catch {
|
|
4658
4834
|
return void 0;
|
|
@@ -4844,7 +5020,7 @@ function describe(finding) {
|
|
|
4844
5020
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
4845
5021
|
}
|
|
4846
5022
|
function runSync(workspaceRoot, options) {
|
|
4847
|
-
if (!fileExists((0,
|
|
5023
|
+
if (!fileExists((0, import_node_path18.join)(workspaceRoot, "nx.json"))) {
|
|
4848
5024
|
throw new Error(
|
|
4849
5025
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
4850
5026
|
);
|
|
@@ -4894,7 +5070,7 @@ function runSync(workspaceRoot, options) {
|
|
|
4894
5070
|
}
|
|
4895
5071
|
|
|
4896
5072
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
4897
|
-
var
|
|
5073
|
+
var import_node_path19 = require("path");
|
|
4898
5074
|
var import_prompts2 = require("@inquirer/prompts");
|
|
4899
5075
|
|
|
4900
5076
|
// src/dependency-management/registry.client.ts
|
|
@@ -5177,7 +5353,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
5177
5353
|
function hasPythonInstallScript(workspaceRoot) {
|
|
5178
5354
|
try {
|
|
5179
5355
|
const manifest = readJson(
|
|
5180
|
-
(0,
|
|
5356
|
+
(0, import_node_path19.join)(workspaceRoot, "package.json")
|
|
5181
5357
|
);
|
|
5182
5358
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
5183
5359
|
} catch {
|
|
@@ -5193,7 +5369,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
5193
5369
|
}
|
|
5194
5370
|
}
|
|
5195
5371
|
async function runUp(workspaceRoot, options) {
|
|
5196
|
-
if (!fileExists((0,
|
|
5372
|
+
if (!fileExists((0, import_node_path19.join)(workspaceRoot, "nx.json"))) {
|
|
5197
5373
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
5198
5374
|
}
|
|
5199
5375
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -5269,7 +5445,7 @@ var PROJECT_KINDS = [
|
|
|
5269
5445
|
];
|
|
5270
5446
|
async function runAdd(kind, name, options) {
|
|
5271
5447
|
const workspaceRoot = process.cwd();
|
|
5272
|
-
if (!fileExists((0,
|
|
5448
|
+
if (!fileExists((0, import_node_path20.join)(workspaceRoot, "nx.json"))) {
|
|
5273
5449
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
5274
5450
|
}
|
|
5275
5451
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -5278,6 +5454,9 @@ async function runAdd(kind, name, options) {
|
|
|
5278
5454
|
message: "What kind of project?",
|
|
5279
5455
|
choices: PROJECT_KINDS.map((value) => ({ name: value, value }))
|
|
5280
5456
|
});
|
|
5457
|
+
if (resolvedKind !== "go-app" && options.release === true) {
|
|
5458
|
+
throw new Error(`--release applies to go-app only, not ${resolvedKind}.`);
|
|
5459
|
+
}
|
|
5281
5460
|
const resolvedName = name ?? await promptText("Project name");
|
|
5282
5461
|
assertValidProjectName(resolvedName, "Project name");
|
|
5283
5462
|
const rootDependenciesBefore = rootRuntimeDependencies(workspaceRoot);
|
|
@@ -5320,8 +5499,8 @@ async function runAdd(kind, name, options) {
|
|
|
5320
5499
|
],
|
|
5321
5500
|
workspaceRoot
|
|
5322
5501
|
);
|
|
5323
|
-
markPrivate((0,
|
|
5324
|
-
renameScaffoldPlaceholder((0,
|
|
5502
|
+
markPrivate((0, import_node_path20.join)(workspaceRoot, "libs", resolvedName, "package.json"));
|
|
5503
|
+
renameScaffoldPlaceholder((0, import_node_path20.join)(workspaceRoot, "libs", resolvedName), resolvedName);
|
|
5325
5504
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
5326
5505
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
5327
5506
|
break;
|
|
@@ -5343,7 +5522,7 @@ async function runAdd(kind, name, options) {
|
|
|
5343
5522
|
break;
|
|
5344
5523
|
}
|
|
5345
5524
|
case "go-app": {
|
|
5346
|
-
addGoApp(workspaceRoot, resolvedName);
|
|
5525
|
+
addGoApp(workspaceRoot, resolvedName, { release: options.release });
|
|
5347
5526
|
break;
|
|
5348
5527
|
}
|
|
5349
5528
|
case "go-function-app": {
|
|
@@ -5413,7 +5592,7 @@ async function runAdd(kind, name, options) {
|
|
|
5413
5592
|
}
|
|
5414
5593
|
function readWorkspaceStack(workspaceRoot) {
|
|
5415
5594
|
const nxJson = readJson(
|
|
5416
|
-
(0,
|
|
5595
|
+
(0, import_node_path20.join)(workspaceRoot, "nx.json")
|
|
5417
5596
|
);
|
|
5418
5597
|
const stack = nxJson.mnci?.stack;
|
|
5419
5598
|
return {
|
|
@@ -5422,15 +5601,15 @@ function readWorkspaceStack(workspaceRoot) {
|
|
|
5422
5601
|
}
|
|
5423
5602
|
|
|
5424
5603
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
5425
|
-
var
|
|
5426
|
-
var
|
|
5604
|
+
var import_node_fs14 = require("fs");
|
|
5605
|
+
var import_node_path21 = require("path");
|
|
5427
5606
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
5428
5607
|
function toPosix2(path) {
|
|
5429
5608
|
return path.replaceAll("\\", "/");
|
|
5430
5609
|
}
|
|
5431
5610
|
function checkEslintConfigs(workspaceRoot) {
|
|
5432
|
-
const rootConfigs = (0,
|
|
5433
|
-
const projectConfigs = (0,
|
|
5611
|
+
const rootConfigs = (0, import_node_fs14.globSync)("eslint.config.{js,mjs,cjs,ts,mts,cts}", { cwd: workspaceRoot });
|
|
5612
|
+
const projectConfigs = (0, import_node_fs14.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
5434
5613
|
cwd: workspaceRoot
|
|
5435
5614
|
}).map((config) => toPosix2(config));
|
|
5436
5615
|
return [
|
|
@@ -5450,10 +5629,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
5450
5629
|
];
|
|
5451
5630
|
}
|
|
5452
5631
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
5453
|
-
const rules = (0,
|
|
5454
|
-
if (!(0,
|
|
5455
|
-
const entryPoint = (0,
|
|
5456
|
-
const source = (0,
|
|
5632
|
+
const rules = (0, import_node_path21.join)(workspaceRoot, ESLINT_MNCI_FILENAME);
|
|
5633
|
+
if (!(0, import_node_fs14.existsSync)(rules)) return [];
|
|
5634
|
+
const entryPoint = (0, import_node_path21.join)(workspaceRoot, ESLINT_USER_FILENAME);
|
|
5635
|
+
const source = (0, import_node_fs14.existsSync)(entryPoint) ? (0, import_node_fs14.readFileSync)(entryPoint, "utf8") : "";
|
|
5457
5636
|
return [
|
|
5458
5637
|
{
|
|
5459
5638
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -5466,7 +5645,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
5466
5645
|
function declaredDevDependencies(workspaceRoot) {
|
|
5467
5646
|
try {
|
|
5468
5647
|
const manifest = readJson(
|
|
5469
|
-
(0,
|
|
5648
|
+
(0, import_node_path21.join)(workspaceRoot, "package.json")
|
|
5470
5649
|
);
|
|
5471
5650
|
return manifest.devDependencies ?? {};
|
|
5472
5651
|
} catch {
|
|
@@ -5474,7 +5653,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
5474
5653
|
}
|
|
5475
5654
|
}
|
|
5476
5655
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
5477
|
-
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0,
|
|
5656
|
+
const files = RETIRED_FORMATTER_FILES.filter((file) => fileExists((0, import_node_path21.join)(workspaceRoot, file)));
|
|
5478
5657
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
5479
5658
|
const stale = [...files, ...declared];
|
|
5480
5659
|
if (stale.length === 0) {
|
|
@@ -5500,7 +5679,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
5500
5679
|
};
|
|
5501
5680
|
}
|
|
5502
5681
|
function checkResolvedEslint(workspaceRoot) {
|
|
5503
|
-
const manifestPath = (0,
|
|
5682
|
+
const manifestPath = (0, import_node_path21.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
5504
5683
|
if (!fileExists(manifestPath)) {
|
|
5505
5684
|
return void 0;
|
|
5506
5685
|
}
|
|
@@ -5518,11 +5697,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
5518
5697
|
}
|
|
5519
5698
|
}
|
|
5520
5699
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
5521
|
-
const npmrcPath = (0,
|
|
5700
|
+
const npmrcPath = (0, import_node_path21.join)(workspaceRoot, ".npmrc");
|
|
5522
5701
|
if (!registry || !fileExists(npmrcPath)) {
|
|
5523
5702
|
return void 0;
|
|
5524
5703
|
}
|
|
5525
|
-
const npmrc = (0,
|
|
5704
|
+
const npmrc = (0, import_node_fs14.readFileSync)(npmrcPath, "utf8");
|
|
5526
5705
|
if (registry.kind === "npm") {
|
|
5527
5706
|
return {
|
|
5528
5707
|
check: ".npmrc authenticates the public registry",
|
|
@@ -5539,11 +5718,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
5539
5718
|
};
|
|
5540
5719
|
}
|
|
5541
5720
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
5542
|
-
const npmrcPath = (0,
|
|
5721
|
+
const npmrcPath = (0, import_node_path21.join)(workspaceRoot, ".npmrc");
|
|
5543
5722
|
if (!fileExists(npmrcPath)) {
|
|
5544
5723
|
return void 0;
|
|
5545
5724
|
}
|
|
5546
|
-
const npmrc = (0,
|
|
5725
|
+
const npmrc = (0, import_node_fs14.readFileSync)(npmrcPath, "utf8");
|
|
5547
5726
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
5548
5727
|
const referenced = [
|
|
5549
5728
|
...new Set(
|
|
@@ -5567,13 +5746,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
5567
5746
|
};
|
|
5568
5747
|
}
|
|
5569
5748
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
5570
|
-
const npmrcPath = (0,
|
|
5571
|
-
const pipelinePath = (0,
|
|
5749
|
+
const npmrcPath = (0, import_node_path21.join)(workspaceRoot, ".npmrc");
|
|
5750
|
+
const pipelinePath = (0, import_node_path21.join)(workspaceRoot, "azure-pipelines.yml");
|
|
5572
5751
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
5573
5752
|
return void 0;
|
|
5574
5753
|
}
|
|
5575
|
-
const holdsCredentials = (0,
|
|
5576
|
-
const runsTask = (0,
|
|
5754
|
+
const holdsCredentials = (0, import_node_fs14.readFileSync)(npmrcPath, "utf8").split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).some((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
5755
|
+
const runsTask = (0, import_node_fs14.readFileSync)(pipelinePath, "utf8").includes("npmAuthenticate@0");
|
|
5577
5756
|
if (!holdsCredentials && !runsTask) {
|
|
5578
5757
|
return {
|
|
5579
5758
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -5618,13 +5797,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
5618
5797
|
}
|
|
5619
5798
|
function checkVersionActions(workspaceRoot) {
|
|
5620
5799
|
const candidates = [
|
|
5621
|
-
...(0,
|
|
5622
|
-
...(0,
|
|
5623
|
-
...(0,
|
|
5800
|
+
...(0, import_node_fs14.globSync)("packages/*/pubspec.yaml", { cwd: workspaceRoot }),
|
|
5801
|
+
...(0, import_node_fs14.globSync)("packages/*/*.csproj", { cwd: workspaceRoot }),
|
|
5802
|
+
...(0, import_node_fs14.globSync)("python-packages/*/pyproject.toml", { cwd: workspaceRoot })
|
|
5624
5803
|
].map((manifest) => toPosix2(manifest));
|
|
5625
5804
|
return candidates.flatMap((manifest) => {
|
|
5626
5805
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
5627
|
-
const projectJsonPath = (0,
|
|
5806
|
+
const projectJsonPath = (0, import_node_path21.join)(workspaceRoot, projectRoot, "project.json");
|
|
5628
5807
|
let hasOverride = false;
|
|
5629
5808
|
try {
|
|
5630
5809
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -5653,7 +5832,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
5653
5832
|
]) {
|
|
5654
5833
|
try {
|
|
5655
5834
|
const targets = extract(
|
|
5656
|
-
readJson((0,
|
|
5835
|
+
readJson((0, import_node_path21.join)(workspaceRoot, projectRoot, file))
|
|
5657
5836
|
);
|
|
5658
5837
|
if (targets && typeof targets === "object") {
|
|
5659
5838
|
sources.push({
|
|
@@ -5669,8 +5848,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
5669
5848
|
function checkTargetFilesExist(workspaceRoot) {
|
|
5670
5849
|
const projectRoots = new Set(
|
|
5671
5850
|
[
|
|
5672
|
-
...(0,
|
|
5673
|
-
...(0,
|
|
5851
|
+
...(0, import_node_fs14.globSync)("{apps,libs,packages}/*/project.json", { cwd: workspaceRoot }),
|
|
5852
|
+
...(0, import_node_fs14.globSync)("{apps,libs,packages}/*/package.json", { cwd: workspaceRoot })
|
|
5674
5853
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
5675
5854
|
);
|
|
5676
5855
|
return [...projectRoots].flatMap(
|
|
@@ -5685,7 +5864,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
5685
5864
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
5686
5865
|
const value = target?.options?.[option];
|
|
5687
5866
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
5688
|
-
if (!checkable || fileExists((0,
|
|
5867
|
+
if (!checkable || fileExists((0, import_node_path21.join)(workspaceRoot, value))) {
|
|
5689
5868
|
return [];
|
|
5690
5869
|
}
|
|
5691
5870
|
return [
|
|
@@ -5707,7 +5886,7 @@ function checkSync(workspaceRoot) {
|
|
|
5707
5886
|
};
|
|
5708
5887
|
}
|
|
5709
5888
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
5710
|
-
const manifestPath = (0,
|
|
5889
|
+
const manifestPath = (0, import_node_path21.join)(workspaceRoot, "package.json");
|
|
5711
5890
|
if (!fileExists(manifestPath)) {
|
|
5712
5891
|
return void 0;
|
|
5713
5892
|
}
|
|
@@ -5727,14 +5906,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
5727
5906
|
};
|
|
5728
5907
|
}
|
|
5729
5908
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
5730
|
-
const configs = (0,
|
|
5909
|
+
const configs = (0, import_node_fs14.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5731
5910
|
cwd: workspaceRoot
|
|
5732
5911
|
}).map((config) => toPosix2(config));
|
|
5733
5912
|
return configs.flatMap((relativePath) => {
|
|
5734
|
-
const configPath = (0,
|
|
5913
|
+
const configPath = (0, import_node_path21.join)(workspaceRoot, relativePath);
|
|
5735
5914
|
let config;
|
|
5736
5915
|
try {
|
|
5737
|
-
config = (0,
|
|
5916
|
+
config = (0, import_node_fs14.readFileSync)(configPath, "utf8");
|
|
5738
5917
|
} catch {
|
|
5739
5918
|
return [];
|
|
5740
5919
|
}
|
|
@@ -5749,11 +5928,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
5749
5928
|
});
|
|
5750
5929
|
}
|
|
5751
5930
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
5752
|
-
const configs = (0,
|
|
5931
|
+
const configs = (0, import_node_fs14.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5753
5932
|
cwd: workspaceRoot
|
|
5754
5933
|
}).map((config) => toPosix2(config));
|
|
5755
5934
|
return configs.flatMap((relativePath) => {
|
|
5756
|
-
const configPath = (0,
|
|
5935
|
+
const configPath = (0, import_node_path21.join)(workspaceRoot, relativePath);
|
|
5757
5936
|
if (!fileExists(configPath)) {
|
|
5758
5937
|
return [];
|
|
5759
5938
|
}
|
|
@@ -5787,7 +5966,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
5787
5966
|
});
|
|
5788
5967
|
}
|
|
5789
5968
|
function collectFindings(workspaceRoot) {
|
|
5790
|
-
const nxJsonPath = (0,
|
|
5969
|
+
const nxJsonPath = (0, import_node_path21.join)(workspaceRoot, "nx.json");
|
|
5791
5970
|
if (!fileExists(nxJsonPath)) {
|
|
5792
5971
|
throw new Error(
|
|
5793
5972
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -5832,8 +6011,8 @@ function runDoctor(workspaceRoot) {
|
|
|
5832
6011
|
}
|
|
5833
6012
|
|
|
5834
6013
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
5835
|
-
var
|
|
5836
|
-
var
|
|
6014
|
+
var import_node_fs15 = require("fs");
|
|
6015
|
+
var import_node_path22 = require("path");
|
|
5837
6016
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
5838
6017
|
var AGENT_AND_CI_ENTRIES = [
|
|
5839
6018
|
"AGENTS.md",
|
|
@@ -5864,13 +6043,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
5864
6043
|
"packages"
|
|
5865
6044
|
];
|
|
5866
6045
|
function assertAdoptableDirectory(target) {
|
|
5867
|
-
if (!(0,
|
|
6046
|
+
if (!(0, import_node_fs15.existsSync)(target)) {
|
|
5868
6047
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
5869
6048
|
}
|
|
5870
|
-
if (!(0,
|
|
6049
|
+
if (!(0, import_node_fs15.statSync)(target).isDirectory()) {
|
|
5871
6050
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
5872
6051
|
}
|
|
5873
|
-
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0,
|
|
6052
|
+
const blockers = PREFLIGHT_BLOCKERS.filter((entry) => (0, import_node_fs15.existsSync)((0, import_node_path22.join)(target, entry)));
|
|
5874
6053
|
if (blockers.length > 0) {
|
|
5875
6054
|
throw new Error(
|
|
5876
6055
|
`--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.`
|
|
@@ -5878,15 +6057,15 @@ function assertAdoptableDirectory(target) {
|
|
|
5878
6057
|
}
|
|
5879
6058
|
}
|
|
5880
6059
|
function mergeGitignore(generatedFile, targetFile) {
|
|
5881
|
-
const existing = (0,
|
|
6060
|
+
const existing = (0, import_node_fs15.readFileSync)(targetFile, "utf8");
|
|
5882
6061
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
5883
|
-
const additions = (0,
|
|
6062
|
+
const additions = (0, import_node_fs15.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
5884
6063
|
const trimmed = line.trim();
|
|
5885
6064
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
5886
6065
|
});
|
|
5887
6066
|
if (additions.length === 0) return false;
|
|
5888
6067
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
5889
|
-
(0,
|
|
6068
|
+
(0, import_node_fs15.writeFileSync)(
|
|
5890
6069
|
targetFile,
|
|
5891
6070
|
`${existing}${separator}
|
|
5892
6071
|
# Added by mnci (Nx workspace)
|
|
@@ -5896,9 +6075,9 @@ ${additions.join("\n")}
|
|
|
5896
6075
|
return true;
|
|
5897
6076
|
}
|
|
5898
6077
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
5899
|
-
const entries = (0,
|
|
6078
|
+
const entries = (0, import_node_fs15.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
5900
6079
|
const collisions = entries.filter(
|
|
5901
|
-
(entry) => (0,
|
|
6080
|
+
(entry) => (0, import_node_fs15.existsSync)((0, import_node_path22.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
5902
6081
|
);
|
|
5903
6082
|
if (collisions.length > 0) {
|
|
5904
6083
|
throw new Error(
|
|
@@ -5907,28 +6086,28 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
5907
6086
|
}
|
|
5908
6087
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
5909
6088
|
for (const entry of entries) {
|
|
5910
|
-
const from = (0,
|
|
5911
|
-
const to = (0,
|
|
5912
|
-
if (entry === ".gitignore" && (0,
|
|
6089
|
+
const from = (0, import_node_path22.join)(generatedRoot, entry);
|
|
6090
|
+
const to = (0, import_node_path22.join)(target, entry);
|
|
6091
|
+
if (entry === ".gitignore" && (0, import_node_fs15.existsSync)(to)) {
|
|
5913
6092
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
5914
6093
|
result.kept.push(entry);
|
|
5915
6094
|
continue;
|
|
5916
6095
|
}
|
|
5917
|
-
if ((0,
|
|
6096
|
+
if ((0, import_node_fs15.existsSync)(to)) {
|
|
5918
6097
|
result.kept.push(entry);
|
|
5919
6098
|
continue;
|
|
5920
6099
|
}
|
|
5921
|
-
(0,
|
|
6100
|
+
(0, import_node_fs15.cpSync)(from, to, { recursive: true });
|
|
5922
6101
|
result.copied.push(entry);
|
|
5923
6102
|
}
|
|
5924
|
-
(0,
|
|
6103
|
+
(0, import_node_fs15.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
5925
6104
|
return result;
|
|
5926
6105
|
}
|
|
5927
6106
|
|
|
5928
6107
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
5929
|
-
var
|
|
6108
|
+
var import_node_fs16 = require("fs");
|
|
5930
6109
|
var import_node_os = require("os");
|
|
5931
|
-
var
|
|
6110
|
+
var import_node_path23 = require("path");
|
|
5932
6111
|
function nxCloudProviderValue(ci) {
|
|
5933
6112
|
return ci === "azure" ? "azure" : "github";
|
|
5934
6113
|
}
|
|
@@ -5964,9 +6143,9 @@ async function resolveRegistry(options) {
|
|
|
5964
6143
|
return await promptRegistry();
|
|
5965
6144
|
}
|
|
5966
6145
|
async function runNew(name, options) {
|
|
5967
|
-
const adoptTarget = options.into === void 0 ? void 0 : (0,
|
|
6146
|
+
const adoptTarget = options.into === void 0 ? void 0 : (0, import_node_path23.resolve)(process.cwd(), options.into);
|
|
5968
6147
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
5969
|
-
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0,
|
|
6148
|
+
const workspaceName = name ?? (adoptTarget === void 0 ? await promptText("Workspace name") : (0, import_node_path23.basename)(adoptTarget));
|
|
5970
6149
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
5971
6150
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
5972
6151
|
const registry = await resolveRegistry(options);
|
|
@@ -5979,8 +6158,8 @@ async function runNew(name, options) {
|
|
|
5979
6158
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
5980
6159
|
const stack = await resolveStack(options);
|
|
5981
6160
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
5982
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
5983
|
-
let workspaceRoot = (0,
|
|
6161
|
+
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0, import_node_fs16.mkdtempSync)((0, import_node_path23.join)((0, import_node_os.tmpdir)(), "mnci-new-"));
|
|
6162
|
+
let workspaceRoot = (0, import_node_path23.join)(stagingParent, workspaceName);
|
|
5984
6163
|
try {
|
|
5985
6164
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
5986
6165
|
runNpx(
|
|
@@ -6003,7 +6182,7 @@ async function runNew(name, options) {
|
|
|
6003
6182
|
workspaceRoot = adoptTarget;
|
|
6004
6183
|
}
|
|
6005
6184
|
} finally {
|
|
6006
|
-
if (adoptTarget !== void 0) (0,
|
|
6185
|
+
if (adoptTarget !== void 0) (0, import_node_fs16.rmSync)(stagingParent, { recursive: true, force: true });
|
|
6007
6186
|
}
|
|
6008
6187
|
logger.step(
|
|
6009
6188
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -6013,8 +6192,8 @@ async function runNew(name, options) {
|
|
|
6013
6192
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
6014
6193
|
logger.detail
|
|
6015
6194
|
);
|
|
6016
|
-
(0,
|
|
6017
|
-
(0,
|
|
6195
|
+
(0, import_node_fs16.rmSync)((0, import_node_path23.join)(workspaceRoot, "node_modules"), { recursive: true, force: true });
|
|
6196
|
+
(0, import_node_fs16.rmSync)((0, import_node_path23.join)(workspaceRoot, "package-lock.json"), { force: true });
|
|
6018
6197
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
6019
6198
|
const installStatus = runShell(
|
|
6020
6199
|
"npm",
|
|
@@ -6045,12 +6224,12 @@ async function runNew(name, options) {
|
|
|
6045
6224
|
}
|
|
6046
6225
|
|
|
6047
6226
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
6048
|
-
var
|
|
6227
|
+
var import_node_path25 = require("path");
|
|
6049
6228
|
var import_prompts4 = require("@inquirer/prompts");
|
|
6050
6229
|
|
|
6051
6230
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
6052
|
-
var
|
|
6053
|
-
var
|
|
6231
|
+
var import_node_fs17 = require("fs");
|
|
6232
|
+
var import_node_path24 = require("path");
|
|
6054
6233
|
function resolveRegistry2(options, persisted) {
|
|
6055
6234
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
6056
6235
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -6079,7 +6258,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
6079
6258
|
return persisted.workspaceName;
|
|
6080
6259
|
}
|
|
6081
6260
|
try {
|
|
6082
|
-
const existing = (0,
|
|
6261
|
+
const existing = (0, import_node_fs17.readdirSync)(workspaceRoot).find(
|
|
6083
6262
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
6084
6263
|
);
|
|
6085
6264
|
if (existing) {
|
|
@@ -6087,11 +6266,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
6087
6266
|
}
|
|
6088
6267
|
} catch {
|
|
6089
6268
|
}
|
|
6090
|
-
return (0,
|
|
6269
|
+
return (0, import_node_path24.basename)(workspaceRoot);
|
|
6091
6270
|
}
|
|
6092
6271
|
function detectNpmAuth(workspaceRoot) {
|
|
6093
6272
|
try {
|
|
6094
|
-
return (0,
|
|
6273
|
+
return (0, import_node_fs17.readFileSync)((0, import_node_path24.join)(workspaceRoot, "azure-pipelines.yml"), "utf8").includes("npmAuthenticate@0") ? "build-identity" : void 0;
|
|
6095
6274
|
} catch {
|
|
6096
6275
|
return void 0;
|
|
6097
6276
|
}
|
|
@@ -6138,7 +6317,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
6138
6317
|
};
|
|
6139
6318
|
}
|
|
6140
6319
|
function runUpgrade(workspaceRoot, options) {
|
|
6141
|
-
if (!fileExists((0,
|
|
6320
|
+
if (!fileExists((0, import_node_path24.join)(workspaceRoot, "nx.json"))) {
|
|
6142
6321
|
throw new Error(
|
|
6143
6322
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
6144
6323
|
);
|
|
@@ -6179,6 +6358,10 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
6179
6358
|
logger.step("Updating the VS Code extension packaging script");
|
|
6180
6359
|
logger.detail(`updated ${VSCODE_EXTENSION_SCRIPT_PATH}`);
|
|
6181
6360
|
}
|
|
6361
|
+
if (refreshGoReleaseScript(workspaceRoot)) {
|
|
6362
|
+
logger.step("Updating the releasable Go app script");
|
|
6363
|
+
logger.detail(`updated ${GO_RELEASE_SCRIPT_PATH}`);
|
|
6364
|
+
}
|
|
6182
6365
|
const upgradedDtsPlugins = upgradeDeclarationSpecifierPlugins(workspaceRoot);
|
|
6183
6366
|
if (upgradedDtsPlugins.length > 0) {
|
|
6184
6367
|
logger.step("Upgrading declaration specifiers to resolve under nodenext");
|
|
@@ -6195,7 +6378,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
6195
6378
|
|
|
6196
6379
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
6197
6380
|
async function runInteractive() {
|
|
6198
|
-
const inWorkspace = fileExists((0,
|
|
6381
|
+
const inWorkspace = fileExists((0, import_node_path25.join)(process.cwd(), "nx.json"));
|
|
6199
6382
|
const choiceNew = { name: "Create a new monorepo", value: "new" };
|
|
6200
6383
|
const choiceAdd = { name: "Add a project to this workspace", value: "add" };
|
|
6201
6384
|
const choiceUpgrade = {
|
|
@@ -6216,8 +6399,8 @@ async function runInteractive() {
|
|
|
6216
6399
|
}
|
|
6217
6400
|
|
|
6218
6401
|
// src/cli-version/check-for-update.use-case.ts
|
|
6219
|
-
var
|
|
6220
|
-
var
|
|
6402
|
+
var import_node_fs18 = require("fs");
|
|
6403
|
+
var import_node_path26 = require("path");
|
|
6221
6404
|
var import_cross_spawn2 = __toESM(require("cross-spawn"));
|
|
6222
6405
|
var PACKAGE_NAME = "@mnci/cli";
|
|
6223
6406
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
@@ -6273,8 +6456,8 @@ function releaseTriple(version) {
|
|
|
6273
6456
|
}
|
|
6274
6457
|
function readCliVersion(packageDirectory) {
|
|
6275
6458
|
try {
|
|
6276
|
-
const manifestPath = (0,
|
|
6277
|
-
const manifest = JSON.parse((0,
|
|
6459
|
+
const manifestPath = (0, import_node_path26.join)(packageDirectory, "..", "package.json");
|
|
6460
|
+
const manifest = JSON.parse((0, import_node_fs18.readFileSync)(manifestPath, "utf8"));
|
|
6278
6461
|
return manifest.version ?? "0.0.0";
|
|
6279
6462
|
} catch {
|
|
6280
6463
|
return "0.0.0";
|
|
@@ -6335,6 +6518,9 @@ function buildProgram(cliVersion) {
|
|
|
6335
6518
|
).option(
|
|
6336
6519
|
"--sidecar <go-app>",
|
|
6337
6520
|
"vscode-extension only: a go-app whose six-platform build ships in the extension, one .vsix per platform"
|
|
6521
|
+
).option(
|
|
6522
|
+
"--release",
|
|
6523
|
+
"go-app only: release the app. Versioned from its git tag, its six-platform zips attached to its GitHub Release"
|
|
6338
6524
|
).action(
|
|
6339
6525
|
async (kind, name, options) => {
|
|
6340
6526
|
await runAdd(kind, name, options);
|