@mnci/cli 4.13.0 → 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 +410 -221
- 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
|
|
@@ -2162,17 +2174,20 @@ function renameScaffoldPlaceholder(projectRoot, name) {
|
|
|
2162
2174
|
(0, import_node_fs3.renameSync)(spec, renamed);
|
|
2163
2175
|
writeFileEnsured(
|
|
2164
2176
|
renamed,
|
|
2165
|
-
(0, import_node_fs3.readFileSync)(renamed, "utf8")
|
|
2177
|
+
repointSpecifier((0, import_node_fs3.readFileSync)(renamed, "utf8"), `./${name}`, `./${name}.use-case`)
|
|
2166
2178
|
);
|
|
2167
2179
|
}
|
|
2168
2180
|
const barrel = (0, import_node_path3.join)(projectRoot, "src", "index.ts");
|
|
2169
2181
|
if ((0, import_node_fs3.existsSync)(barrel)) {
|
|
2170
2182
|
writeFileEnsured(
|
|
2171
2183
|
barrel,
|
|
2172
|
-
(0, import_node_fs3.readFileSync)(barrel, "utf8")
|
|
2184
|
+
repointSpecifier((0, import_node_fs3.readFileSync)(barrel, "utf8"), `./lib/${name}`, `./lib/${name}.use-case`)
|
|
2173
2185
|
);
|
|
2174
2186
|
}
|
|
2175
2187
|
}
|
|
2188
|
+
function repointSpecifier(source, from, to) {
|
|
2189
|
+
return source.replaceAll(`${from}'`, () => `${to}'`).replaceAll(`${from}.js'`, () => `${to}.js'`);
|
|
2190
|
+
}
|
|
2176
2191
|
function ensureNxPeerOverrides(workspaceRoot) {
|
|
2177
2192
|
const manifestPath = (0, import_node_path3.join)(workspaceRoot, "package.json");
|
|
2178
2193
|
if (!(0, import_node_fs3.existsSync)(manifestPath)) {
|
|
@@ -2602,8 +2617,169 @@ function addFlutterInternalLib(workspaceRoot, name) {
|
|
|
2602
2617
|
}
|
|
2603
2618
|
|
|
2604
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
|
|
2605
2624
|
var import_node_fs5 = require("fs");
|
|
2606
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
|
|
2607
2783
|
function ensureGo(workspaceRoot) {
|
|
2608
2784
|
if (runShell("go", ["version"], workspaceRoot) !== 0) {
|
|
2609
2785
|
throw new Error("Go not found. Install Go 1.21+ first: https://go.dev/dl/");
|
|
@@ -2630,7 +2806,7 @@ function ensureNxGoPlugin(workspaceRoot) {
|
|
|
2630
2806
|
}
|
|
2631
2807
|
}
|
|
2632
2808
|
function ensureGoModule(workspaceRoot) {
|
|
2633
|
-
if (fileExists((0,
|
|
2809
|
+
if (fileExists((0, import_node_path7.join)(workspaceRoot, "go.mod"))) {
|
|
2634
2810
|
return;
|
|
2635
2811
|
}
|
|
2636
2812
|
logger.step("Bootstrapping the workspace Go module (single root go.mod)");
|
|
@@ -2639,7 +2815,7 @@ function ensureGoModule(workspaceRoot) {
|
|
|
2639
2815
|
}
|
|
2640
2816
|
function goModulePath(workspaceRoot) {
|
|
2641
2817
|
try {
|
|
2642
|
-
const contents = (0,
|
|
2818
|
+
const contents = (0, import_node_fs6.readFileSync)((0, import_node_path7.join)(workspaceRoot, "go.mod"), "utf8");
|
|
2643
2819
|
return /^module\s+(\S+)/m.exec(contents)?.[1];
|
|
2644
2820
|
} catch {
|
|
2645
2821
|
return void 0;
|
|
@@ -2701,16 +2877,16 @@ function goPackageAllTarget(tag, name) {
|
|
|
2701
2877
|
}
|
|
2702
2878
|
function addGoPlatformTargets(workspaceRoot) {
|
|
2703
2879
|
const changed = [];
|
|
2704
|
-
const apps = (0,
|
|
2880
|
+
const apps = (0, import_node_path7.join)(workspaceRoot, "apps");
|
|
2705
2881
|
if (!fileExists(apps)) {
|
|
2706
2882
|
return changed;
|
|
2707
2883
|
}
|
|
2708
|
-
for (const name of (0,
|
|
2709
|
-
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");
|
|
2710
2886
|
if (!fileExists(projectJsonPath)) {
|
|
2711
2887
|
continue;
|
|
2712
2888
|
}
|
|
2713
|
-
const project = JSON.parse((0,
|
|
2889
|
+
const project = JSON.parse((0, import_node_fs6.readFileSync)(projectJsonPath, "utf8"));
|
|
2714
2890
|
const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
|
|
2715
2891
|
if (tag === void 0) {
|
|
2716
2892
|
continue;
|
|
@@ -2746,8 +2922,8 @@ function goLibraryIdentifiers(projectName) {
|
|
|
2746
2922
|
}
|
|
2747
2923
|
function reshapeGoLibraryScaffold(projectRoot, projectName) {
|
|
2748
2924
|
const { packageName, functionName, fileStem } = goLibraryIdentifiers(projectName);
|
|
2749
|
-
(0,
|
|
2750
|
-
(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 });
|
|
2751
2927
|
const files = [
|
|
2752
2928
|
[
|
|
2753
2929
|
"doc.go",
|
|
@@ -2757,14 +2933,14 @@ package ${packageName}
|
|
|
2757
2933
|
`
|
|
2758
2934
|
],
|
|
2759
2935
|
[
|
|
2760
|
-
(0,
|
|
2936
|
+
(0, import_node_path7.join)(packageName, "doc.go"),
|
|
2761
2937
|
`// Package ${packageName} is the starter slice of ${projectName}: rename it after
|
|
2762
2938
|
// the outcome it delivers, and add one package per further outcome.
|
|
2763
2939
|
package ${packageName}
|
|
2764
2940
|
`
|
|
2765
2941
|
],
|
|
2766
2942
|
[
|
|
2767
|
-
(0,
|
|
2943
|
+
(0, import_node_path7.join)(packageName, `${fileStem}_use_case.go`),
|
|
2768
2944
|
`package ${packageName}
|
|
2769
2945
|
|
|
2770
2946
|
// ${functionName} is the generator's sample behaviour, kept so the slice builds and tests.
|
|
@@ -2774,7 +2950,7 @@ func ${functionName}(name string) string {
|
|
|
2774
2950
|
`
|
|
2775
2951
|
],
|
|
2776
2952
|
[
|
|
2777
|
-
(0,
|
|
2953
|
+
(0, import_node_path7.join)(packageName, `${fileStem}_use_case_test.go`),
|
|
2778
2954
|
`package ${packageName}
|
|
2779
2955
|
|
|
2780
2956
|
import "testing"
|
|
@@ -2788,7 +2964,7 @@ func Test${functionName}(t *testing.T) {
|
|
|
2788
2964
|
]
|
|
2789
2965
|
];
|
|
2790
2966
|
for (const [relativePath, content] of files) {
|
|
2791
|
-
const path = (0,
|
|
2967
|
+
const path = (0, import_node_path7.join)(projectRoot, relativePath);
|
|
2792
2968
|
if (!fileExists(path)) {
|
|
2793
2969
|
writeFileEnsured(path, content);
|
|
2794
2970
|
}
|
|
@@ -2801,7 +2977,7 @@ function prepareGo(workspaceRoot) {
|
|
|
2801
2977
|
ensureNxGoPlugin(workspaceRoot);
|
|
2802
2978
|
ensureGoModule(workspaceRoot);
|
|
2803
2979
|
}
|
|
2804
|
-
function addGoApp(workspaceRoot, name) {
|
|
2980
|
+
function addGoApp(workspaceRoot, name, options = {}) {
|
|
2805
2981
|
prepareGo(workspaceRoot);
|
|
2806
2982
|
ensureAdmZip(workspaceRoot);
|
|
2807
2983
|
runNx(
|
|
@@ -2815,7 +2991,7 @@ function addGoApp(workspaceRoot, name) {
|
|
|
2815
2991
|
],
|
|
2816
2992
|
workspaceRoot
|
|
2817
2993
|
);
|
|
2818
|
-
addProjectJsonTargets((0,
|
|
2994
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
2819
2995
|
"build": goBuildTarget(name),
|
|
2820
2996
|
"test": goTestTarget(),
|
|
2821
2997
|
"lint": goLintTarget(),
|
|
@@ -2824,6 +3000,9 @@ function addGoApp(workspaceRoot, name) {
|
|
|
2824
3000
|
"package-all": goPackageAllTarget("go-app", name),
|
|
2825
3001
|
"start": goStartTarget(name)
|
|
2826
3002
|
});
|
|
3003
|
+
if (options.release === true) {
|
|
3004
|
+
makeGoAppReleasable(workspaceRoot, name);
|
|
3005
|
+
}
|
|
2827
3006
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
|
|
2828
3007
|
}
|
|
2829
3008
|
function addGoFunctionApp(workspaceRoot, name) {
|
|
@@ -2840,7 +3019,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
2840
3019
|
],
|
|
2841
3020
|
workspaceRoot
|
|
2842
3021
|
);
|
|
2843
|
-
addProjectJsonTargets((0,
|
|
3022
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
2844
3023
|
"build": goBuildTarget(name),
|
|
2845
3024
|
"test": goTestTarget(),
|
|
2846
3025
|
"lint": goLintTarget(),
|
|
@@ -2863,11 +3042,11 @@ function addGoLib(workspaceRoot, name) {
|
|
|
2863
3042
|
],
|
|
2864
3043
|
workspaceRoot
|
|
2865
3044
|
);
|
|
2866
|
-
addProjectJsonTargets((0,
|
|
3045
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
2867
3046
|
test: goTestTarget(),
|
|
2868
3047
|
lint: goLintTarget()
|
|
2869
3048
|
});
|
|
2870
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3049
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path7.join)(workspaceRoot, "packages", name), name);
|
|
2871
3050
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
2872
3051
|
const module2 = goModulePath(workspaceRoot);
|
|
2873
3052
|
if (module2) {
|
|
@@ -2887,11 +3066,11 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
2887
3066
|
],
|
|
2888
3067
|
workspaceRoot
|
|
2889
3068
|
);
|
|
2890
|
-
addProjectJsonTargets((0,
|
|
3069
|
+
addProjectJsonTargets((0, import_node_path7.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
2891
3070
|
test: goTestTarget(),
|
|
2892
3071
|
lint: goLintTarget()
|
|
2893
3072
|
});
|
|
2894
|
-
const slice = reshapeGoLibraryScaffold((0,
|
|
3073
|
+
const slice = reshapeGoLibraryScaffold((0, import_node_path7.join)(workspaceRoot, "libs", name), name);
|
|
2895
3074
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
2896
3075
|
const module2 = goModulePath(workspaceRoot);
|
|
2897
3076
|
if (module2) {
|
|
@@ -2900,7 +3079,7 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
2900
3079
|
}
|
|
2901
3080
|
|
|
2902
3081
|
// src/project-scaffolding/node.use-case.ts
|
|
2903
|
-
var
|
|
3082
|
+
var import_node_path8 = require("path");
|
|
2904
3083
|
function ensurePlugin2(workspaceRoot, packageName) {
|
|
2905
3084
|
if (hasPlugin(workspaceRoot, packageName)) {
|
|
2906
3085
|
return;
|
|
@@ -2924,12 +3103,12 @@ function runNodeApp(workspaceRoot, name, stack, framework) {
|
|
|
2924
3103
|
],
|
|
2925
3104
|
workspaceRoot
|
|
2926
3105
|
);
|
|
2927
|
-
const appRoot = (0,
|
|
3106
|
+
const appRoot = (0, import_node_path8.join)(workspaceRoot, "apps", name);
|
|
2928
3107
|
separateDeclarationOutput(appRoot);
|
|
2929
3108
|
repairAssetMapping(appRoot, name);
|
|
2930
3109
|
}
|
|
2931
3110
|
function separateDeclarationOutput(appRoot) {
|
|
2932
|
-
const tsconfigPath = (0,
|
|
3111
|
+
const tsconfigPath = (0, import_node_path8.join)(appRoot, "tsconfig.app.json");
|
|
2933
3112
|
if (!fileExists(tsconfigPath)) {
|
|
2934
3113
|
return;
|
|
2935
3114
|
}
|
|
@@ -2951,7 +3130,7 @@ function separateDeclarationOutput(appRoot) {
|
|
|
2951
3130
|
);
|
|
2952
3131
|
}
|
|
2953
3132
|
function repairAssetMapping(appRoot, name) {
|
|
2954
|
-
const manifestPath = (0,
|
|
3133
|
+
const manifestPath = (0, import_node_path8.join)(appRoot, "package.json");
|
|
2955
3134
|
if (!fileExists(manifestPath)) {
|
|
2956
3135
|
return;
|
|
2957
3136
|
}
|
|
@@ -2978,7 +3157,7 @@ function nodeAppPackageTarget(name) {
|
|
|
2978
3157
|
function addNodeApp(workspaceRoot, name, stack, framework = "none") {
|
|
2979
3158
|
runNodeApp(workspaceRoot, name, stack, framework);
|
|
2980
3159
|
ensureAdmZip(workspaceRoot);
|
|
2981
|
-
addNxTargets((0,
|
|
3160
|
+
addNxTargets((0, import_node_path8.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
2982
3161
|
package: nodeAppPackageTarget(name)
|
|
2983
3162
|
});
|
|
2984
3163
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
@@ -3034,10 +3213,10 @@ describe('buildGreeting', () => {
|
|
|
3034
3213
|
})
|
|
3035
3214
|
`;
|
|
3036
3215
|
function repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot) {
|
|
3037
|
-
const manifestPath = (0,
|
|
3216
|
+
const manifestPath = (0, import_node_path8.join)(nodeFunctionAppRoot, "package.json");
|
|
3038
3217
|
const manifest = readJson(manifestPath);
|
|
3039
3218
|
const azureFunctionsVersion = readJson(
|
|
3040
|
-
(0,
|
|
3219
|
+
(0, import_node_path8.join)(workspaceRoot, "node_modules/@azure/functions/package.json")
|
|
3041
3220
|
).version;
|
|
3042
3221
|
const dependencies = manifest.dependencies ?? {};
|
|
3043
3222
|
writeFileEnsured(
|
|
@@ -3080,21 +3259,21 @@ function nodeFunctionAppStartTarget(name) {
|
|
|
3080
3259
|
function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
3081
3260
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
3082
3261
|
ensureAzureFunctionsPackage(workspaceRoot);
|
|
3083
|
-
const nodeFunctionAppRoot = (0,
|
|
3084
|
-
writeFileEnsured((0,
|
|
3085
|
-
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);
|
|
3086
3265
|
writeFileEnsured(
|
|
3087
|
-
(0,
|
|
3266
|
+
(0, import_node_path8.join)(nodeFunctionAppRoot, "src/functions/greeting.ts"),
|
|
3088
3267
|
NODE_FUNCTION_APP_GREETING
|
|
3089
3268
|
);
|
|
3090
3269
|
writeFileEnsured(
|
|
3091
|
-
(0,
|
|
3270
|
+
(0, import_node_path8.join)(nodeFunctionAppRoot, "src/functions/greeting.spec.ts"),
|
|
3092
3271
|
NODE_FUNCTION_APP_GREETING_SPEC
|
|
3093
3272
|
);
|
|
3094
|
-
writeFileEnsured((0,
|
|
3273
|
+
writeFileEnsured((0, import_node_path8.join)(nodeFunctionAppRoot, "host.json"), NODE_FUNCTION_APP_HOST_JSON);
|
|
3095
3274
|
repairNodeFunctionAppManifest(nodeFunctionAppRoot, workspaceRoot);
|
|
3096
3275
|
ensureAdmZip(workspaceRoot);
|
|
3097
|
-
addNxTargets((0,
|
|
3276
|
+
addNxTargets((0, import_node_path8.join)(nodeFunctionAppRoot, "package.json"), {
|
|
3098
3277
|
package: nodeFunctionAppPackageTarget(name),
|
|
3099
3278
|
prune: nodeFunctionAppPruneTarget(name),
|
|
3100
3279
|
start: nodeFunctionAppStartTarget(name)
|
|
@@ -3104,11 +3283,11 @@ function addNodeFunctionApp(workspaceRoot, name, stack) {
|
|
|
3104
3283
|
}
|
|
3105
3284
|
|
|
3106
3285
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
3107
|
-
var
|
|
3286
|
+
var import_node_path12 = require("path");
|
|
3108
3287
|
|
|
3109
3288
|
// src/rollup-library/repair-publishable-manifest.use-case.ts
|
|
3110
|
-
var
|
|
3111
|
-
var
|
|
3289
|
+
var import_node_fs7 = require("fs");
|
|
3290
|
+
var import_node_path9 = require("path");
|
|
3112
3291
|
var WRONG_TYPES_PATH = "./dist/index.esm.d.ts";
|
|
3113
3292
|
var ACTUAL_TYPES_PATH = "./dist/src/index.d.ts";
|
|
3114
3293
|
var DECLARATION_MAP_EXCLUSION = "!**/*.d.ts.map";
|
|
@@ -3131,14 +3310,14 @@ function repairPublishableManifest(manifestPath) {
|
|
|
3131
3310
|
}
|
|
3132
3311
|
function repairPublishableManifests(workspaceRoot) {
|
|
3133
3312
|
const changed = [];
|
|
3134
|
-
const manifests = (0,
|
|
3313
|
+
const manifests = (0, import_node_fs7.globSync)(["packages/*/package.json", "libs/*/package.json"], {
|
|
3135
3314
|
cwd: workspaceRoot
|
|
3136
3315
|
});
|
|
3137
3316
|
for (const relativePath of manifests) {
|
|
3138
|
-
const manifestPath = (0,
|
|
3139
|
-
const before = (0,
|
|
3317
|
+
const manifestPath = (0, import_node_path9.join)(workspaceRoot, relativePath);
|
|
3318
|
+
const before = (0, import_node_fs7.readFileSync)(manifestPath, "utf8");
|
|
3140
3319
|
repairPublishableManifest(manifestPath);
|
|
3141
|
-
const after = (0,
|
|
3320
|
+
const after = (0, import_node_fs7.readFileSync)(manifestPath, "utf8");
|
|
3142
3321
|
if (after !== before) {
|
|
3143
3322
|
changed.push(relativePath.replaceAll("\\", "/"));
|
|
3144
3323
|
}
|
|
@@ -3147,8 +3326,8 @@ function repairPublishableManifests(workspaceRoot) {
|
|
|
3147
3326
|
}
|
|
3148
3327
|
|
|
3149
3328
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
3150
|
-
var
|
|
3151
|
-
var
|
|
3329
|
+
var import_node_fs8 = require("fs");
|
|
3330
|
+
var import_node_path10 = require("path");
|
|
3152
3331
|
|
|
3153
3332
|
// src/rollup-library/rollup-config.algorithm.ts
|
|
3154
3333
|
var ROLLUP_CONFIG_PLACEHOLDER = [
|
|
@@ -3350,12 +3529,12 @@ function withUpgradedDeclarationSpecifierPlugin(config) {
|
|
|
3350
3529
|
// src/rollup-library/repair-rollup-config.use-case.ts
|
|
3351
3530
|
function repairRollupSourceMaps(workspaceRoot) {
|
|
3352
3531
|
const changed = [];
|
|
3353
|
-
const configs = (0,
|
|
3532
|
+
const configs = (0, import_node_fs8.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
3354
3533
|
cwd: workspaceRoot
|
|
3355
3534
|
});
|
|
3356
3535
|
for (const relativePath of configs) {
|
|
3357
|
-
const configPath = (0,
|
|
3358
|
-
const before = (0,
|
|
3536
|
+
const configPath = (0, import_node_path10.join)(workspaceRoot, relativePath);
|
|
3537
|
+
const before = (0, import_node_fs8.readFileSync)(configPath, "utf8");
|
|
3359
3538
|
const after = withRollupSourceMaps(before);
|
|
3360
3539
|
if (after !== before) {
|
|
3361
3540
|
writeFileEnsured(configPath, after);
|
|
@@ -3366,12 +3545,12 @@ function repairRollupSourceMaps(workspaceRoot) {
|
|
|
3366
3545
|
}
|
|
3367
3546
|
function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
3368
3547
|
const changed = [];
|
|
3369
|
-
const configs = (0,
|
|
3548
|
+
const configs = (0, import_node_fs8.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
3370
3549
|
cwd: workspaceRoot
|
|
3371
3550
|
});
|
|
3372
3551
|
for (const relativePath of configs) {
|
|
3373
|
-
const configPath = (0,
|
|
3374
|
-
const before = (0,
|
|
3552
|
+
const configPath = (0, import_node_path10.join)(workspaceRoot, relativePath);
|
|
3553
|
+
const before = (0, import_node_fs8.readFileSync)(configPath, "utf8");
|
|
3375
3554
|
const after = withUpgradedDeclarationSpecifierPlugin(before);
|
|
3376
3555
|
if (after !== before) {
|
|
3377
3556
|
writeFileEnsured(configPath, after);
|
|
@@ -3381,11 +3560,11 @@ function upgradeDeclarationSpecifierPlugins(workspaceRoot) {
|
|
|
3381
3560
|
return changed;
|
|
3382
3561
|
}
|
|
3383
3562
|
function repairDeclarationSpecifiers(projectRoot) {
|
|
3384
|
-
const configPath = (0,
|
|
3563
|
+
const configPath = (0, import_node_path10.join)(projectRoot, "rollup.config.cjs");
|
|
3385
3564
|
if (!fileExists(configPath)) {
|
|
3386
3565
|
return;
|
|
3387
3566
|
}
|
|
3388
|
-
const config = (0,
|
|
3567
|
+
const config = (0, import_node_fs8.readFileSync)(configPath, "utf8");
|
|
3389
3568
|
if (!config.includes(ROLLUP_CONFIG_PLACEHOLDER)) {
|
|
3390
3569
|
return;
|
|
3391
3570
|
}
|
|
@@ -3394,10 +3573,10 @@ function repairDeclarationSpecifiers(projectRoot) {
|
|
|
3394
3573
|
}
|
|
3395
3574
|
|
|
3396
3575
|
// src/rollup-library/rollup-config.repository.ts
|
|
3397
|
-
var
|
|
3398
|
-
var
|
|
3576
|
+
var import_node_fs9 = require("fs");
|
|
3577
|
+
var import_node_path11 = require("path");
|
|
3399
3578
|
function resolveRequireTarget(fromDir, specifier) {
|
|
3400
|
-
const base = (0,
|
|
3579
|
+
const base = (0, import_node_path11.join)(fromDir, specifier);
|
|
3401
3580
|
return [base, `${base}.cjs`, `${base}.js`].find((candidate) => fileExists(candidate));
|
|
3402
3581
|
}
|
|
3403
3582
|
function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()) {
|
|
@@ -3407,7 +3586,7 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
3407
3586
|
visited.add(configPath);
|
|
3408
3587
|
let text;
|
|
3409
3588
|
try {
|
|
3410
|
-
text = (0,
|
|
3589
|
+
text = (0, import_node_fs9.readFileSync)(configPath, "utf8");
|
|
3411
3590
|
} catch {
|
|
3412
3591
|
return "";
|
|
3413
3592
|
}
|
|
@@ -3415,15 +3594,15 @@ function resolveRollupConfigText(configPath, visited = /* @__PURE__ */ new Set()
|
|
|
3415
3594
|
text.matchAll(/require\((['"])(\.[^'"]*)\1\)/g),
|
|
3416
3595
|
(match) => match[2]
|
|
3417
3596
|
);
|
|
3418
|
-
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));
|
|
3419
3598
|
return [text, ...requiredText].join("\n");
|
|
3420
3599
|
}
|
|
3421
3600
|
|
|
3422
3601
|
// src/project-scaffolding/npm-lib.use-case.ts
|
|
3423
3602
|
async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
3424
3603
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
3425
|
-
const projectRoot = (0,
|
|
3426
|
-
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");
|
|
3427
3606
|
runGeneratorAndRepair(
|
|
3428
3607
|
workspaceRoot,
|
|
3429
3608
|
[
|
|
@@ -3452,8 +3631,8 @@ async function addNpmLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
3452
3631
|
}
|
|
3453
3632
|
|
|
3454
3633
|
// src/project-scaffolding/python.use-case.ts
|
|
3455
|
-
var
|
|
3456
|
-
var
|
|
3634
|
+
var import_node_fs10 = require("fs");
|
|
3635
|
+
var import_node_path13 = require("path");
|
|
3457
3636
|
function ensurePython(workspaceRoot) {
|
|
3458
3637
|
const hasPython = runShell("python3", ["--version"], workspaceRoot) === 0 || runShell("python", ["--version"], workspaceRoot) === 0;
|
|
3459
3638
|
if (!hasPython) {
|
|
@@ -3476,7 +3655,7 @@ function ensurePythonPipPlugin(workspaceRoot) {
|
|
|
3476
3655
|
registerPythonGraphPlugin(workspaceRoot);
|
|
3477
3656
|
}
|
|
3478
3657
|
function registerPythonGraphPlugin(workspaceRoot) {
|
|
3479
|
-
const nxJsonPath = (0,
|
|
3658
|
+
const nxJsonPath = (0, import_node_path13.join)(workspaceRoot, "nx.json");
|
|
3480
3659
|
if (!fileExists(nxJsonPath)) {
|
|
3481
3660
|
return;
|
|
3482
3661
|
}
|
|
@@ -3499,7 +3678,7 @@ pytest
|
|
|
3499
3678
|
pip-audit
|
|
3500
3679
|
`;
|
|
3501
3680
|
function ensureRequirementsDev(workspaceRoot) {
|
|
3502
|
-
const requirementsDevPath = (0,
|
|
3681
|
+
const requirementsDevPath = (0, import_node_path13.join)(workspaceRoot, "requirements-dev.txt");
|
|
3503
3682
|
if (!fileExists(requirementsDevPath)) {
|
|
3504
3683
|
writeFileEnsured(requirementsDevPath, PYTHON_REQUIREMENTS_DEV);
|
|
3505
3684
|
}
|
|
@@ -3559,8 +3738,8 @@ function addPythonApp(workspaceRoot, name) {
|
|
|
3559
3738
|
["g", "@mnci/nx-python-pip:application", name, `--directory=apps/${name}`, "--no-interactive"],
|
|
3560
3739
|
workspaceRoot
|
|
3561
3740
|
);
|
|
3562
|
-
writeFileEnsured((0,
|
|
3563
|
-
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"), {
|
|
3564
3743
|
package: pythonAppPackageTarget(name),
|
|
3565
3744
|
start: pythonAppStartTarget(name)
|
|
3566
3745
|
});
|
|
@@ -3582,7 +3761,7 @@ function addPythonFunctionApp(workspaceRoot, name) {
|
|
|
3582
3761
|
workspaceRoot
|
|
3583
3762
|
);
|
|
3584
3763
|
const moduleDirectory = pythonModuleDirectory(name);
|
|
3585
|
-
addProjectJsonTargets((0,
|
|
3764
|
+
addProjectJsonTargets((0, import_node_path13.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
3586
3765
|
package: pythonFunctionAppPackageTarget(name, moduleDirectory),
|
|
3587
3766
|
start: pythonFunctionAppStartTarget(name)
|
|
3588
3767
|
});
|
|
@@ -3623,7 +3802,7 @@ function addPythonInternalLib(workspaceRoot, name) {
|
|
|
3623
3802
|
var PYTHON_PROJECT_DIRS = ["apps", "python-packages", "libs"];
|
|
3624
3803
|
function findPythonProjectDirectory(workspaceRoot, name) {
|
|
3625
3804
|
return PYTHON_PROJECT_DIRS.find(
|
|
3626
|
-
(directory) => fileExists((0,
|
|
3805
|
+
(directory) => fileExists((0, import_node_path13.join)(workspaceRoot, directory, name, "pyproject.toml"))
|
|
3627
3806
|
);
|
|
3628
3807
|
}
|
|
3629
3808
|
function parseVendorEntries(pyprojectToml) {
|
|
@@ -3662,7 +3841,7 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
3662
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.`
|
|
3663
3842
|
);
|
|
3664
3843
|
}
|
|
3665
|
-
if (!fileExists((0,
|
|
3844
|
+
if (!fileExists((0, import_node_path13.join)(workspaceRoot, "libs", lib, "pyproject.toml"))) {
|
|
3666
3845
|
throw new Error(
|
|
3667
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.`
|
|
3668
3847
|
);
|
|
@@ -3670,8 +3849,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
3670
3849
|
if (consumerDirectory === "libs" && consumer === lib) {
|
|
3671
3850
|
throw new Error(`'${consumer}' cannot vendor itself.`);
|
|
3672
3851
|
}
|
|
3673
|
-
const pyprojectPath = (0,
|
|
3674
|
-
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");
|
|
3675
3854
|
if (parseVendorEntries(pyprojectToml).includes(lib)) {
|
|
3676
3855
|
logger.info(`'${consumer}' already vendors '${lib}' \u2014 nothing to do.`);
|
|
3677
3856
|
return;
|
|
@@ -3683,8 +3862,8 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
3683
3862
|
}
|
|
3684
3863
|
|
|
3685
3864
|
// src/project-scaffolding/react-app.use-case.ts
|
|
3686
|
-
var
|
|
3687
|
-
var
|
|
3865
|
+
var import_node_fs11 = require("fs");
|
|
3866
|
+
var import_node_path14 = require("path");
|
|
3688
3867
|
var REACT_ENVIRONMENTS = ["dev", "uat", "prod"];
|
|
3689
3868
|
function reactEnvironmentFile(environment) {
|
|
3690
3869
|
return `# Vite compiles VITE_-prefixed vars into the '${environment}' bundle at build time.
|
|
@@ -3721,12 +3900,12 @@ function reactAppTargets(name) {
|
|
|
3721
3900
|
return targets;
|
|
3722
3901
|
}
|
|
3723
3902
|
function allowEnvFiles(workspaceRoot) {
|
|
3724
|
-
const gitignorePath = (0,
|
|
3903
|
+
const gitignorePath = (0, import_node_path14.join)(workspaceRoot, ".gitignore");
|
|
3725
3904
|
if (!fileExists(gitignorePath)) {
|
|
3726
3905
|
return;
|
|
3727
3906
|
}
|
|
3728
3907
|
const marker = "# MoNecromanCI: keep the committed per-environment Vite config (public VITE_ values)";
|
|
3729
|
-
const current = (0,
|
|
3908
|
+
const current = (0, import_node_fs11.readFileSync)(gitignorePath, "utf8");
|
|
3730
3909
|
if (current.includes(marker)) {
|
|
3731
3910
|
return;
|
|
3732
3911
|
}
|
|
@@ -3753,24 +3932,24 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
3753
3932
|
workspaceRoot
|
|
3754
3933
|
);
|
|
3755
3934
|
ensureAdmZip(workspaceRoot);
|
|
3756
|
-
const reactAppRoot = (0,
|
|
3935
|
+
const reactAppRoot = (0, import_node_path14.join)(workspaceRoot, "apps", name);
|
|
3757
3936
|
for (const environment of REACT_ENVIRONMENTS) {
|
|
3758
|
-
writeFileEnsured((0,
|
|
3937
|
+
writeFileEnsured((0, import_node_path14.join)(reactAppRoot, `.env.${environment}`), reactEnvironmentFile(environment));
|
|
3759
3938
|
}
|
|
3760
3939
|
allowEnvFiles(workspaceRoot);
|
|
3761
|
-
addNxTargets((0,
|
|
3940
|
+
addNxTargets((0, import_node_path14.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
3762
3941
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
3763
3942
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
3764
3943
|
}
|
|
3765
3944
|
|
|
3766
3945
|
// src/project-scaffolding/react-lib.use-case.ts
|
|
3767
|
-
var
|
|
3946
|
+
var import_node_path15 = require("path");
|
|
3768
3947
|
var REACT_LIB_BUNDLER = "rollup";
|
|
3769
3948
|
async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
3770
3949
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
3771
3950
|
const scope = options.scope ?? (kindProvided ? defaultScope(workspaceRoot) : await promptText("npm scope for the published package", defaultScope(workspaceRoot)));
|
|
3772
|
-
const projectRoot = (0,
|
|
3773
|
-
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");
|
|
3774
3953
|
runGeneratorAndRepair(
|
|
3775
3954
|
workspaceRoot,
|
|
3776
3955
|
[
|
|
@@ -3799,8 +3978,8 @@ async function addReactLib(workspaceRoot, name, options, kindProvided, stack) {
|
|
|
3799
3978
|
}
|
|
3800
3979
|
function addReactInternalLib(workspaceRoot, name, stack) {
|
|
3801
3980
|
ensurePlugin(workspaceRoot, "@nx/react");
|
|
3802
|
-
const projectRoot = (0,
|
|
3803
|
-
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");
|
|
3804
3983
|
runGeneratorAndRepair(
|
|
3805
3984
|
workspaceRoot,
|
|
3806
3985
|
[
|
|
@@ -3826,8 +4005,8 @@ function addReactInternalLib(workspaceRoot, name, stack) {
|
|
|
3826
4005
|
}
|
|
3827
4006
|
|
|
3828
4007
|
// src/project-scaffolding/vscode-extension.use-case.ts
|
|
3829
|
-
var
|
|
3830
|
-
var
|
|
4008
|
+
var import_node_fs12 = require("fs");
|
|
4009
|
+
var import_node_path16 = require("path");
|
|
3831
4010
|
var VSCODE_EXTENSION_SCRIPT_PATH = "tools/vscode-extension.cjs";
|
|
3832
4011
|
var VSCODE_SIDECAR_TARGETS = {
|
|
3833
4012
|
"win32-x64": "windows-amd64",
|
|
@@ -4011,8 +4190,8 @@ export const window = {
|
|
|
4011
4190
|
var VSCODE_STUB_PATH = "test/vscode.stub.ts";
|
|
4012
4191
|
function mapVscodeToStub(projectRoot, testRunner) {
|
|
4013
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}\` },`];
|
|
4014
|
-
const path = (0,
|
|
4015
|
-
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") : "";
|
|
4016
4195
|
const line = content.split("\n").find((candidate) => candidate.trim() === anchor);
|
|
4017
4196
|
if (line === void 0) {
|
|
4018
4197
|
throw new Error(`${file} has no "${anchor}" line to map the vscode module after; map 'vscode' to ${VSCODE_STUB_PATH} by hand.`);
|
|
@@ -4032,11 +4211,11 @@ function ensureVscodeToolchain(workspaceRoot) {
|
|
|
4032
4211
|
}
|
|
4033
4212
|
}
|
|
4034
4213
|
function defaultPublisher(workspaceRoot) {
|
|
4035
|
-
const { name } = readJson((0,
|
|
4214
|
+
const { name } = readJson((0, import_node_path16.join)(workspaceRoot, "package.json"));
|
|
4036
4215
|
return (name ?? "publisher").replace(/^@/, "").split("/", 1)[0];
|
|
4037
4216
|
}
|
|
4038
4217
|
function reshapeManifest(projectRoot, name, publisher, typesVersion) {
|
|
4039
|
-
const manifestPath = (0,
|
|
4218
|
+
const manifestPath = (0, import_node_path16.join)(projectRoot, "package.json");
|
|
4040
4219
|
const manifest = readJson(manifestPath);
|
|
4041
4220
|
const { nx = {}, ...rest } = manifest;
|
|
4042
4221
|
const targets = { ...nx.targets };
|
|
@@ -4100,11 +4279,11 @@ function vscodeExtensionPublishTarget(name, sidecar) {
|
|
|
4100
4279
|
};
|
|
4101
4280
|
}
|
|
4102
4281
|
function addDebugLaunch(workspaceRoot, name) {
|
|
4103
|
-
const file = (0,
|
|
4282
|
+
const file = (0, import_node_fs12.readdirSync)(workspaceRoot).find((entry) => entry.endsWith(".code-workspace"));
|
|
4104
4283
|
if (file === void 0) {
|
|
4105
4284
|
return;
|
|
4106
4285
|
}
|
|
4107
|
-
const path = (0,
|
|
4286
|
+
const path = (0, import_node_path16.join)(workspaceRoot, file);
|
|
4108
4287
|
const workspace = readCodeWorkspace(path) ?? {};
|
|
4109
4288
|
const folder = `\${workspaceFolder:${workspace.folders?.[0]?.name ?? file.replace(/\.code-workspace$/, "")}}`;
|
|
4110
4289
|
const taskLabel = `${name}: build (development)`;
|
|
@@ -4137,39 +4316,39 @@ function addDebugLaunch(workspaceRoot, name) {
|
|
|
4137
4316
|
);
|
|
4138
4317
|
}
|
|
4139
4318
|
function refreshVscodeExtensionScript(workspaceRoot) {
|
|
4140
|
-
const apps = (0,
|
|
4319
|
+
const apps = (0, import_node_path16.join)(workspaceRoot, "apps");
|
|
4141
4320
|
let entries;
|
|
4142
4321
|
try {
|
|
4143
|
-
entries = (0,
|
|
4322
|
+
entries = (0, import_node_fs12.readdirSync)(apps);
|
|
4144
4323
|
} catch {
|
|
4145
4324
|
return false;
|
|
4146
4325
|
}
|
|
4147
4326
|
const hasExtension = entries.some((entry) => {
|
|
4148
|
-
const manifestPath = (0,
|
|
4327
|
+
const manifestPath = (0, import_node_path16.join)(apps, entry, "package.json");
|
|
4149
4328
|
if (!fileExists(manifestPath)) {
|
|
4150
4329
|
return false;
|
|
4151
4330
|
}
|
|
4152
4331
|
const tags = readJson(manifestPath).nx?.tags ?? [];
|
|
4153
4332
|
return tags.includes(VSCODE_EXTENSION_TAG);
|
|
4154
4333
|
});
|
|
4155
|
-
const path = (0,
|
|
4156
|
-
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) {
|
|
4157
4336
|
return false;
|
|
4158
4337
|
}
|
|
4159
4338
|
writeFileEnsured(path, VSCODE_EXTENSION_SCRIPT);
|
|
4160
4339
|
return true;
|
|
4161
4340
|
}
|
|
4162
4341
|
function pinVscodeExtensionProjectNames(workspaceRoot) {
|
|
4163
|
-
const apps = (0,
|
|
4342
|
+
const apps = (0, import_node_path16.join)(workspaceRoot, "apps");
|
|
4164
4343
|
let entries;
|
|
4165
4344
|
try {
|
|
4166
|
-
entries = (0,
|
|
4345
|
+
entries = (0, import_node_fs12.readdirSync)(apps);
|
|
4167
4346
|
} catch {
|
|
4168
4347
|
return [];
|
|
4169
4348
|
}
|
|
4170
4349
|
const updated = [];
|
|
4171
4350
|
for (const entry of entries) {
|
|
4172
|
-
const manifestPath = (0,
|
|
4351
|
+
const manifestPath = (0, import_node_path16.join)(apps, entry, "package.json");
|
|
4173
4352
|
if (!fileExists(manifestPath)) {
|
|
4174
4353
|
continue;
|
|
4175
4354
|
}
|
|
@@ -4189,23 +4368,23 @@ function refreshLockFile(workspaceRoot, name) {
|
|
|
4189
4368
|
}
|
|
4190
4369
|
function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
4191
4370
|
const { sidecar } = options;
|
|
4192
|
-
if (sidecar !== void 0 && !fileExists((0,
|
|
4371
|
+
if (sidecar !== void 0 && !fileExists((0, import_node_path16.join)(workspaceRoot, "apps", sidecar, "project.json"))) {
|
|
4193
4372
|
throw new Error(`--sidecar ${sidecar}: no Go app at apps/${sidecar}. Add it first with \`mnci add go-app ${sidecar}\`.`);
|
|
4194
4373
|
}
|
|
4195
4374
|
runNodeApp(workspaceRoot, name, stack, "none");
|
|
4196
4375
|
ensureVscodeToolchain(workspaceRoot);
|
|
4197
|
-
const projectRoot = (0,
|
|
4198
|
-
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;
|
|
4199
4378
|
reshapeManifest(projectRoot, name, options.publisher ?? defaultPublisher(workspaceRoot), typesVersion);
|
|
4200
|
-
addVscodeTypes((0,
|
|
4201
|
-
addVscodeTypes((0,
|
|
4202
|
-
writeFileEnsured((0,
|
|
4203
|
-
writeFileEnsured((0,
|
|
4204
|
-
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);
|
|
4205
4384
|
mapVscodeToStub(projectRoot, stack.testRunner);
|
|
4206
|
-
writeFileEnsured((0,
|
|
4207
|
-
writeFileEnsured((0,
|
|
4208
|
-
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"), {
|
|
4209
4388
|
"package": vscodeExtensionPackageTarget(name, sidecar),
|
|
4210
4389
|
"nx-release-publish": vscodeExtensionPublishTarget(name, sidecar)
|
|
4211
4390
|
});
|
|
@@ -4216,11 +4395,11 @@ function addVscodeExtension(workspaceRoot, name, stack, options = {}) {
|
|
|
4216
4395
|
}
|
|
4217
4396
|
|
|
4218
4397
|
// src/dependency-management/sync-dependencies.use-case.ts
|
|
4219
|
-
var
|
|
4398
|
+
var import_node_path18 = require("path");
|
|
4220
4399
|
|
|
4221
4400
|
// src/dependency-management/manifest.repository.ts
|
|
4222
|
-
var
|
|
4223
|
-
var
|
|
4401
|
+
var import_node_fs13 = require("fs");
|
|
4402
|
+
var import_node_path17 = require("path");
|
|
4224
4403
|
var ECOSYSTEMS = ["npm", "pip", "pub", "nuget", "go"];
|
|
4225
4404
|
var ROOT_LABEL = "(root)";
|
|
4226
4405
|
var MANIFEST_GLOBS = {
|
|
@@ -4253,23 +4432,23 @@ function projectOf(manifestRelativePath) {
|
|
|
4253
4432
|
}
|
|
4254
4433
|
function hasEcosystem(workspaceRoot, ecosystem) {
|
|
4255
4434
|
if (ecosystem === "go") {
|
|
4256
|
-
return fileExists((0,
|
|
4435
|
+
return fileExists((0, import_node_path17.join)(workspaceRoot, "go.mod"));
|
|
4257
4436
|
}
|
|
4258
4437
|
if (ecosystem === "nuget") {
|
|
4259
|
-
return (0,
|
|
4438
|
+
return (0, import_node_fs13.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot }).length > 0;
|
|
4260
4439
|
}
|
|
4261
4440
|
const rootMarker = {
|
|
4262
4441
|
npm: "package.json",
|
|
4263
4442
|
pip: "requirements-dev.txt",
|
|
4264
4443
|
pub: "pubspec.yaml"
|
|
4265
4444
|
};
|
|
4266
|
-
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;
|
|
4267
4446
|
}
|
|
4268
4447
|
function collectNpm(workspaceRoot) {
|
|
4269
4448
|
const sites = [];
|
|
4270
|
-
const relativePaths = ["package.json", ...(0,
|
|
4449
|
+
const relativePaths = ["package.json", ...(0, import_node_fs13.globSync)(MANIFEST_GLOBS.npm, { cwd: workspaceRoot })];
|
|
4271
4450
|
for (const relativePath of relativePaths) {
|
|
4272
|
-
const manifestPath = (0,
|
|
4451
|
+
const manifestPath = (0, import_node_path17.join)(workspaceRoot, relativePath);
|
|
4273
4452
|
try {
|
|
4274
4453
|
const manifest = readJson(manifestPath);
|
|
4275
4454
|
sites.push(...npmManifestSites(manifest, relativePath, manifestPath));
|
|
@@ -4330,17 +4509,17 @@ function collectPip(workspaceRoot) {
|
|
|
4330
4509
|
name: parsed.name,
|
|
4331
4510
|
ecosystem: "pip",
|
|
4332
4511
|
project: projectOf(relativePath),
|
|
4333
|
-
manifestPath: (0,
|
|
4512
|
+
manifestPath: (0, import_node_path17.join)(workspaceRoot, relativePath),
|
|
4334
4513
|
section,
|
|
4335
4514
|
spec: parsed.spec,
|
|
4336
4515
|
rewritable: parsed.rewritable && parsed.spec !== ""
|
|
4337
4516
|
});
|
|
4338
4517
|
};
|
|
4339
|
-
const pyprojectPaths = (0,
|
|
4518
|
+
const pyprojectPaths = (0, import_node_fs13.globSync)(MANIFEST_GLOBS.pip, { cwd: workspaceRoot });
|
|
4340
4519
|
for (const relativePath of pyprojectPaths) {
|
|
4341
4520
|
let content;
|
|
4342
4521
|
try {
|
|
4343
|
-
content = (0,
|
|
4522
|
+
content = (0, import_node_fs13.readFileSync)((0, import_node_path17.join)(workspaceRoot, relativePath), "utf8");
|
|
4344
4523
|
} catch {
|
|
4345
4524
|
continue;
|
|
4346
4525
|
}
|
|
@@ -4351,14 +4530,14 @@ function collectPip(workspaceRoot) {
|
|
|
4351
4530
|
}
|
|
4352
4531
|
const requirementsPaths = [
|
|
4353
4532
|
"requirements-dev.txt",
|
|
4354
|
-
...(0,
|
|
4533
|
+
...(0, import_node_fs13.globSync)("apps/*/requirements.txt", { cwd: workspaceRoot })
|
|
4355
4534
|
];
|
|
4356
4535
|
for (const relativePath of requirementsPaths) {
|
|
4357
|
-
if (!fileExists((0,
|
|
4536
|
+
if (!fileExists((0, import_node_path17.join)(workspaceRoot, relativePath))) {
|
|
4358
4537
|
continue;
|
|
4359
4538
|
}
|
|
4360
4539
|
const section = relativePath === "requirements-dev.txt" ? "devDep" : "dep";
|
|
4361
|
-
const lines = (0,
|
|
4540
|
+
const lines = (0, import_node_fs13.readFileSync)((0, import_node_path17.join)(workspaceRoot, relativePath), "utf8").split(/\r?\n/);
|
|
4362
4541
|
for (const line of lines) {
|
|
4363
4542
|
push(relativePath, section, line);
|
|
4364
4543
|
}
|
|
@@ -4396,11 +4575,11 @@ function pyprojectDependencies(content) {
|
|
|
4396
4575
|
}
|
|
4397
4576
|
function collectPub(workspaceRoot) {
|
|
4398
4577
|
const sites = [];
|
|
4399
|
-
const pubspecPaths = (0,
|
|
4578
|
+
const pubspecPaths = (0, import_node_fs13.globSync)(MANIFEST_GLOBS.pub, { cwd: workspaceRoot });
|
|
4400
4579
|
for (const relativePath of pubspecPaths) {
|
|
4401
4580
|
let content;
|
|
4402
4581
|
try {
|
|
4403
|
-
content = (0,
|
|
4582
|
+
content = (0, import_node_fs13.readFileSync)((0, import_node_path17.join)(workspaceRoot, relativePath), "utf8");
|
|
4404
4583
|
} catch {
|
|
4405
4584
|
continue;
|
|
4406
4585
|
}
|
|
@@ -4410,7 +4589,7 @@ function collectPub(workspaceRoot) {
|
|
|
4410
4589
|
name: entry.name,
|
|
4411
4590
|
ecosystem: "pub",
|
|
4412
4591
|
project: projectOf(relativePath),
|
|
4413
|
-
manifestPath: (0,
|
|
4592
|
+
manifestPath: (0, import_node_path17.join)(workspaceRoot, relativePath),
|
|
4414
4593
|
section: block === "dependencies" ? "dep" : "devDep",
|
|
4415
4594
|
spec: entry.spec,
|
|
4416
4595
|
rewritable: entry.spec !== ""
|
|
@@ -4460,11 +4639,11 @@ function stripQuotes(value) {
|
|
|
4460
4639
|
}
|
|
4461
4640
|
function collectNuget(workspaceRoot) {
|
|
4462
4641
|
const sites = [];
|
|
4463
|
-
const csprojPaths = (0,
|
|
4642
|
+
const csprojPaths = (0, import_node_fs13.globSync)(MANIFEST_GLOBS.nuget, { cwd: workspaceRoot });
|
|
4464
4643
|
for (const relativePath of csprojPaths) {
|
|
4465
4644
|
let content;
|
|
4466
4645
|
try {
|
|
4467
|
-
content = (0,
|
|
4646
|
+
content = (0, import_node_fs13.readFileSync)((0, import_node_path17.join)(workspaceRoot, relativePath), "utf8");
|
|
4468
4647
|
} catch {
|
|
4469
4648
|
continue;
|
|
4470
4649
|
}
|
|
@@ -4473,7 +4652,7 @@ function collectNuget(workspaceRoot) {
|
|
|
4473
4652
|
name: entry.name,
|
|
4474
4653
|
ecosystem: "nuget",
|
|
4475
4654
|
project: projectOf(relativePath),
|
|
4476
|
-
manifestPath: (0,
|
|
4655
|
+
manifestPath: (0, import_node_path17.join)(workspaceRoot, relativePath),
|
|
4477
4656
|
section: "dep",
|
|
4478
4657
|
spec: entry.spec,
|
|
4479
4658
|
// A plain SemVer string is rewritable; an MSBuild property reference
|
|
@@ -4498,13 +4677,13 @@ function csprojPackageReferences(content) {
|
|
|
4498
4677
|
return entries;
|
|
4499
4678
|
}
|
|
4500
4679
|
function collectGo(workspaceRoot) {
|
|
4501
|
-
const manifestPath = (0,
|
|
4680
|
+
const manifestPath = (0, import_node_path17.join)(workspaceRoot, "go.mod");
|
|
4502
4681
|
if (!fileExists(manifestPath)) {
|
|
4503
4682
|
return [];
|
|
4504
4683
|
}
|
|
4505
4684
|
let content;
|
|
4506
4685
|
try {
|
|
4507
|
-
content = (0,
|
|
4686
|
+
content = (0, import_node_fs13.readFileSync)(manifestPath, "utf8");
|
|
4508
4687
|
} catch {
|
|
4509
4688
|
return [];
|
|
4510
4689
|
}
|
|
@@ -4561,7 +4740,7 @@ function rewriteSpec(site, spec) {
|
|
|
4561
4740
|
writeFileEnsured(site.manifestPath, toJson(manifest));
|
|
4562
4741
|
return true;
|
|
4563
4742
|
}
|
|
4564
|
-
const before = (0,
|
|
4743
|
+
const before = (0, import_node_fs13.readFileSync)(site.manifestPath, "utf8");
|
|
4565
4744
|
const after = (() => {
|
|
4566
4745
|
switch (site.ecosystem) {
|
|
4567
4746
|
case "pip": {
|
|
@@ -4617,13 +4796,13 @@ function escapeForRegex(value) {
|
|
|
4617
4796
|
function isWorkspaceProject(workspaceRoot, name) {
|
|
4618
4797
|
const short = name.includes("/") ? name.split("/").at(-1) : name;
|
|
4619
4798
|
return ["apps", "libs", "packages"].some(
|
|
4620
|
-
(directory) => fileExists((0,
|
|
4799
|
+
(directory) => fileExists((0, import_node_path17.join)(workspaceRoot, directory, short ?? name, "package.json"))
|
|
4621
4800
|
);
|
|
4622
4801
|
}
|
|
4623
4802
|
function isAliasedInstall(workspaceRoot, name) {
|
|
4624
4803
|
try {
|
|
4625
4804
|
const installed = readJson(
|
|
4626
|
-
(0,
|
|
4805
|
+
(0, import_node_path17.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
4627
4806
|
);
|
|
4628
4807
|
return installed.name !== void 0 && installed.name !== name;
|
|
4629
4808
|
} catch {
|
|
@@ -4634,14 +4813,14 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
4634
4813
|
if (ecosystem === "npm") {
|
|
4635
4814
|
try {
|
|
4636
4815
|
return readJson(
|
|
4637
|
-
(0,
|
|
4816
|
+
(0, import_node_path17.join)(workspaceRoot, "node_modules", name, "package.json")
|
|
4638
4817
|
).version;
|
|
4639
4818
|
} catch {
|
|
4640
4819
|
return void 0;
|
|
4641
4820
|
}
|
|
4642
4821
|
}
|
|
4643
4822
|
if (ecosystem === "pub") {
|
|
4644
|
-
const lockPath = (0,
|
|
4823
|
+
const lockPath = (0, import_node_path17.join)(workspaceRoot, "pubspec.lock");
|
|
4645
4824
|
if (!fileExists(lockPath)) {
|
|
4646
4825
|
return void 0;
|
|
4647
4826
|
}
|
|
@@ -4649,7 +4828,7 @@ function resolvedVersion(workspaceRoot, ecosystem, name) {
|
|
|
4649
4828
|
const match = new RegExp(
|
|
4650
4829
|
String.raw`^\s{2}${escapeForRegex(name)}:[^]*?^\s+version:\s*["']?([^"'\s]+)`,
|
|
4651
4830
|
"m"
|
|
4652
|
-
).exec((0,
|
|
4831
|
+
).exec((0, import_node_fs13.readFileSync)(lockPath, "utf8"));
|
|
4653
4832
|
return match?.[1];
|
|
4654
4833
|
} catch {
|
|
4655
4834
|
return void 0;
|
|
@@ -4841,7 +5020,7 @@ function describe(finding) {
|
|
|
4841
5020
|
return `${finding.name} \u2192 ${finding.target} (${finding.reason}); disagreeing: ${sites}`;
|
|
4842
5021
|
}
|
|
4843
5022
|
function runSync(workspaceRoot, options) {
|
|
4844
|
-
if (!fileExists((0,
|
|
5023
|
+
if (!fileExists((0, import_node_path18.join)(workspaceRoot, "nx.json"))) {
|
|
4845
5024
|
throw new Error(
|
|
4846
5025
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci sync' from the workspace root.`
|
|
4847
5026
|
);
|
|
@@ -4891,7 +5070,7 @@ function runSync(workspaceRoot, options) {
|
|
|
4891
5070
|
}
|
|
4892
5071
|
|
|
4893
5072
|
// src/dependency-management/update-dependencies.use-case.ts
|
|
4894
|
-
var
|
|
5073
|
+
var import_node_path19 = require("path");
|
|
4895
5074
|
var import_prompts2 = require("@inquirer/prompts");
|
|
4896
5075
|
|
|
4897
5076
|
// src/dependency-management/registry.client.ts
|
|
@@ -5174,7 +5353,7 @@ function reinstall(workspaceRoot, ecosystems) {
|
|
|
5174
5353
|
function hasPythonInstallScript(workspaceRoot) {
|
|
5175
5354
|
try {
|
|
5176
5355
|
const manifest = readJson(
|
|
5177
|
-
(0,
|
|
5356
|
+
(0, import_node_path19.join)(workspaceRoot, "package.json")
|
|
5178
5357
|
);
|
|
5179
5358
|
return manifest.scripts?.["python:install"] !== void 0;
|
|
5180
5359
|
} catch {
|
|
@@ -5190,7 +5369,7 @@ function applyGoUpdates(workspaceRoot, entries) {
|
|
|
5190
5369
|
}
|
|
5191
5370
|
}
|
|
5192
5371
|
async function runUp(workspaceRoot, options) {
|
|
5193
|
-
if (!fileExists((0,
|
|
5372
|
+
if (!fileExists((0, import_node_path19.join)(workspaceRoot, "nx.json"))) {
|
|
5194
5373
|
throw new Error(`No nx.json found in ${workspaceRoot} \u2014 run 'mnci up' from the workspace root.`);
|
|
5195
5374
|
}
|
|
5196
5375
|
const ecosystems = resolveEcosystems(options.ecosystem);
|
|
@@ -5266,7 +5445,7 @@ var PROJECT_KINDS = [
|
|
|
5266
5445
|
];
|
|
5267
5446
|
async function runAdd(kind, name, options) {
|
|
5268
5447
|
const workspaceRoot = process.cwd();
|
|
5269
|
-
if (!fileExists((0,
|
|
5448
|
+
if (!fileExists((0, import_node_path20.join)(workspaceRoot, "nx.json"))) {
|
|
5270
5449
|
throw new Error("No nx.json found here. Run `add` from the workspace root.");
|
|
5271
5450
|
}
|
|
5272
5451
|
const stack = readWorkspaceStack(workspaceRoot);
|
|
@@ -5275,6 +5454,9 @@ async function runAdd(kind, name, options) {
|
|
|
5275
5454
|
message: "What kind of project?",
|
|
5276
5455
|
choices: PROJECT_KINDS.map((value) => ({ name: value, value }))
|
|
5277
5456
|
});
|
|
5457
|
+
if (resolvedKind !== "go-app" && options.release === true) {
|
|
5458
|
+
throw new Error(`--release applies to go-app only, not ${resolvedKind}.`);
|
|
5459
|
+
}
|
|
5278
5460
|
const resolvedName = name ?? await promptText("Project name");
|
|
5279
5461
|
assertValidProjectName(resolvedName, "Project name");
|
|
5280
5462
|
const rootDependenciesBefore = rootRuntimeDependencies(workspaceRoot);
|
|
@@ -5317,8 +5499,8 @@ async function runAdd(kind, name, options) {
|
|
|
5317
5499
|
],
|
|
5318
5500
|
workspaceRoot
|
|
5319
5501
|
);
|
|
5320
|
-
markPrivate((0,
|
|
5321
|
-
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);
|
|
5322
5504
|
removeGeneratedEslintConfig(workspaceRoot, `libs/${resolvedName}`);
|
|
5323
5505
|
registerProjectCommands(workspaceRoot, resolvedName, { build: true });
|
|
5324
5506
|
break;
|
|
@@ -5340,7 +5522,7 @@ async function runAdd(kind, name, options) {
|
|
|
5340
5522
|
break;
|
|
5341
5523
|
}
|
|
5342
5524
|
case "go-app": {
|
|
5343
|
-
addGoApp(workspaceRoot, resolvedName);
|
|
5525
|
+
addGoApp(workspaceRoot, resolvedName, { release: options.release });
|
|
5344
5526
|
break;
|
|
5345
5527
|
}
|
|
5346
5528
|
case "go-function-app": {
|
|
@@ -5410,7 +5592,7 @@ async function runAdd(kind, name, options) {
|
|
|
5410
5592
|
}
|
|
5411
5593
|
function readWorkspaceStack(workspaceRoot) {
|
|
5412
5594
|
const nxJson = readJson(
|
|
5413
|
-
(0,
|
|
5595
|
+
(0, import_node_path20.join)(workspaceRoot, "nx.json")
|
|
5414
5596
|
);
|
|
5415
5597
|
const stack = nxJson.mnci?.stack;
|
|
5416
5598
|
return {
|
|
@@ -5419,15 +5601,15 @@ function readWorkspaceStack(workspaceRoot) {
|
|
|
5419
5601
|
}
|
|
5420
5602
|
|
|
5421
5603
|
// src/workspace-diagnostics/check-invariants.use-case.ts
|
|
5422
|
-
var
|
|
5423
|
-
var
|
|
5604
|
+
var import_node_fs14 = require("fs");
|
|
5605
|
+
var import_node_path21 = require("path");
|
|
5424
5606
|
var SUPPORTED_ESLINT_MAJOR = ESLINT_VERSION.replace(/^\D*/, "").split(".", 1)[0];
|
|
5425
5607
|
function toPosix2(path) {
|
|
5426
5608
|
return path.replaceAll("\\", "/");
|
|
5427
5609
|
}
|
|
5428
5610
|
function checkEslintConfigs(workspaceRoot) {
|
|
5429
|
-
const rootConfigs = (0,
|
|
5430
|
-
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}", {
|
|
5431
5613
|
cwd: workspaceRoot
|
|
5432
5614
|
}).map((config) => toPosix2(config));
|
|
5433
5615
|
return [
|
|
@@ -5447,10 +5629,10 @@ function checkEslintConfigs(workspaceRoot) {
|
|
|
5447
5629
|
];
|
|
5448
5630
|
}
|
|
5449
5631
|
function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
5450
|
-
const rules = (0,
|
|
5451
|
-
if (!(0,
|
|
5452
|
-
const entryPoint = (0,
|
|
5453
|
-
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") : "";
|
|
5454
5636
|
return [
|
|
5455
5637
|
{
|
|
5456
5638
|
check: `${ESLINT_USER_FILENAME} imports the mnci rules`,
|
|
@@ -5463,7 +5645,7 @@ function checkEslintEntryPointReachesTheRules(workspaceRoot) {
|
|
|
5463
5645
|
function declaredDevDependencies(workspaceRoot) {
|
|
5464
5646
|
try {
|
|
5465
5647
|
const manifest = readJson(
|
|
5466
|
-
(0,
|
|
5648
|
+
(0, import_node_path21.join)(workspaceRoot, "package.json")
|
|
5467
5649
|
);
|
|
5468
5650
|
return manifest.devDependencies ?? {};
|
|
5469
5651
|
} catch {
|
|
@@ -5471,7 +5653,7 @@ function declaredDevDependencies(workspaceRoot) {
|
|
|
5471
5653
|
}
|
|
5472
5654
|
}
|
|
5473
5655
|
function checkNoRetiredFormatter(workspaceRoot) {
|
|
5474
|
-
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)));
|
|
5475
5657
|
const declared = ["prettier", "eslint-config-prettier", "oxlint", "oxfmt", "@mnci/oxlint-config"].filter((name) => declaredDevDependencies(workspaceRoot)[name] !== void 0);
|
|
5476
5658
|
const stale = [...files, ...declared];
|
|
5477
5659
|
if (stale.length === 0) {
|
|
@@ -5497,7 +5679,7 @@ function checkEslintPlugin(nxJson) {
|
|
|
5497
5679
|
};
|
|
5498
5680
|
}
|
|
5499
5681
|
function checkResolvedEslint(workspaceRoot) {
|
|
5500
|
-
const manifestPath = (0,
|
|
5682
|
+
const manifestPath = (0, import_node_path21.join)(workspaceRoot, "node_modules/eslint/package.json");
|
|
5501
5683
|
if (!fileExists(manifestPath)) {
|
|
5502
5684
|
return void 0;
|
|
5503
5685
|
}
|
|
@@ -5515,11 +5697,11 @@ function checkResolvedEslint(workspaceRoot) {
|
|
|
5515
5697
|
}
|
|
5516
5698
|
}
|
|
5517
5699
|
function checkNpmrc(workspaceRoot, registry, scope) {
|
|
5518
|
-
const npmrcPath = (0,
|
|
5700
|
+
const npmrcPath = (0, import_node_path21.join)(workspaceRoot, ".npmrc");
|
|
5519
5701
|
if (!registry || !fileExists(npmrcPath)) {
|
|
5520
5702
|
return void 0;
|
|
5521
5703
|
}
|
|
5522
|
-
const npmrc = (0,
|
|
5704
|
+
const npmrc = (0, import_node_fs14.readFileSync)(npmrcPath, "utf8");
|
|
5523
5705
|
if (registry.kind === "npm") {
|
|
5524
5706
|
return {
|
|
5525
5707
|
check: ".npmrc authenticates the public registry",
|
|
@@ -5536,11 +5718,11 @@ function checkNpmrc(workspaceRoot, registry, scope) {
|
|
|
5536
5718
|
};
|
|
5537
5719
|
}
|
|
5538
5720
|
function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env) {
|
|
5539
|
-
const npmrcPath = (0,
|
|
5721
|
+
const npmrcPath = (0, import_node_path21.join)(workspaceRoot, ".npmrc");
|
|
5540
5722
|
if (!fileExists(npmrcPath)) {
|
|
5541
5723
|
return void 0;
|
|
5542
5724
|
}
|
|
5543
|
-
const npmrc = (0,
|
|
5725
|
+
const npmrc = (0, import_node_fs14.readFileSync)(npmrcPath, "utf8");
|
|
5544
5726
|
const credentials = npmrc.split("\n").filter((line) => !line.trimStart().startsWith(";") && !line.trimStart().startsWith("#")).filter((line) => /(?:_authToken|_password|_auth)\s*=/u.test(line));
|
|
5545
5727
|
const referenced = [
|
|
5546
5728
|
...new Set(
|
|
@@ -5564,13 +5746,13 @@ function checkNpmrcCredentialResolves(workspaceRoot, environment = process.env)
|
|
|
5564
5746
|
};
|
|
5565
5747
|
}
|
|
5566
5748
|
function checkNpmAuthMatchesPipeline(workspaceRoot, registry) {
|
|
5567
|
-
const npmrcPath = (0,
|
|
5568
|
-
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");
|
|
5569
5751
|
if (registry?.kind !== "azure-artifacts" || !fileExists(npmrcPath) || !fileExists(pipelinePath)) {
|
|
5570
5752
|
return void 0;
|
|
5571
5753
|
}
|
|
5572
|
-
const holdsCredentials = (0,
|
|
5573
|
-
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");
|
|
5574
5756
|
if (!holdsCredentials && !runsTask) {
|
|
5575
5757
|
return {
|
|
5576
5758
|
check: "npm auth: .npmrc and azure-pipelines.yml agree",
|
|
@@ -5615,13 +5797,13 @@ function npmjsCredentialShape(credentials, environment) {
|
|
|
5615
5797
|
}
|
|
5616
5798
|
function checkVersionActions(workspaceRoot) {
|
|
5617
5799
|
const candidates = [
|
|
5618
|
-
...(0,
|
|
5619
|
-
...(0,
|
|
5620
|
-
...(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 })
|
|
5621
5803
|
].map((manifest) => toPosix2(manifest));
|
|
5622
5804
|
return candidates.flatMap((manifest) => {
|
|
5623
5805
|
const projectRoot = manifest.slice(0, manifest.lastIndexOf("/"));
|
|
5624
|
-
const projectJsonPath = (0,
|
|
5806
|
+
const projectJsonPath = (0, import_node_path21.join)(workspaceRoot, projectRoot, "project.json");
|
|
5625
5807
|
let hasOverride = false;
|
|
5626
5808
|
try {
|
|
5627
5809
|
const projectJson = readJson(projectJsonPath);
|
|
@@ -5650,7 +5832,7 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
5650
5832
|
]) {
|
|
5651
5833
|
try {
|
|
5652
5834
|
const targets = extract(
|
|
5653
|
-
readJson((0,
|
|
5835
|
+
readJson((0, import_node_path21.join)(workspaceRoot, projectRoot, file))
|
|
5654
5836
|
);
|
|
5655
5837
|
if (targets && typeof targets === "object") {
|
|
5656
5838
|
sources.push({
|
|
@@ -5666,8 +5848,8 @@ function declaredTargets(workspaceRoot, projectRoot) {
|
|
|
5666
5848
|
function checkTargetFilesExist(workspaceRoot) {
|
|
5667
5849
|
const projectRoots = new Set(
|
|
5668
5850
|
[
|
|
5669
|
-
...(0,
|
|
5670
|
-
...(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 })
|
|
5671
5853
|
].map((manifest) => toPosix2(manifest).split("/").slice(0, 2).join("/"))
|
|
5672
5854
|
);
|
|
5673
5855
|
return [...projectRoots].flatMap(
|
|
@@ -5682,7 +5864,7 @@ function checkOneTargetsFiles(workspaceRoot, source, targetName, target) {
|
|
|
5682
5864
|
return TARGET_FILE_OPTIONS.flatMap((option) => {
|
|
5683
5865
|
const value = target?.options?.[option];
|
|
5684
5866
|
const checkable = typeof value === "string" && !value.includes("{");
|
|
5685
|
-
if (!checkable || fileExists((0,
|
|
5867
|
+
if (!checkable || fileExists((0, import_node_path21.join)(workspaceRoot, value))) {
|
|
5686
5868
|
return [];
|
|
5687
5869
|
}
|
|
5688
5870
|
return [
|
|
@@ -5704,7 +5886,7 @@ function checkSync(workspaceRoot) {
|
|
|
5704
5886
|
};
|
|
5705
5887
|
}
|
|
5706
5888
|
function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
5707
|
-
const manifestPath = (0,
|
|
5889
|
+
const manifestPath = (0, import_node_path21.join)(workspaceRoot, "package.json");
|
|
5708
5890
|
if (!fileExists(manifestPath)) {
|
|
5709
5891
|
return void 0;
|
|
5710
5892
|
}
|
|
@@ -5724,14 +5906,14 @@ function checkNoRootRuntimeDependencies(workspaceRoot) {
|
|
|
5724
5906
|
};
|
|
5725
5907
|
}
|
|
5726
5908
|
function checkRollupSourceMaps(workspaceRoot) {
|
|
5727
|
-
const configs = (0,
|
|
5909
|
+
const configs = (0, import_node_fs14.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5728
5910
|
cwd: workspaceRoot
|
|
5729
5911
|
}).map((config) => toPosix2(config));
|
|
5730
5912
|
return configs.flatMap((relativePath) => {
|
|
5731
|
-
const configPath = (0,
|
|
5913
|
+
const configPath = (0, import_node_path21.join)(workspaceRoot, relativePath);
|
|
5732
5914
|
let config;
|
|
5733
5915
|
try {
|
|
5734
|
-
config = (0,
|
|
5916
|
+
config = (0, import_node_fs14.readFileSync)(configPath, "utf8");
|
|
5735
5917
|
} catch {
|
|
5736
5918
|
return [];
|
|
5737
5919
|
}
|
|
@@ -5746,11 +5928,11 @@ function checkRollupSourceMaps(workspaceRoot) {
|
|
|
5746
5928
|
});
|
|
5747
5929
|
}
|
|
5748
5930
|
function checkDeclarationSpecifiers(workspaceRoot) {
|
|
5749
|
-
const configs = (0,
|
|
5931
|
+
const configs = (0, import_node_fs14.globSync)(["packages/*/rollup.config.cjs", "libs/*/rollup.config.cjs"], {
|
|
5750
5932
|
cwd: workspaceRoot
|
|
5751
5933
|
}).map((config) => toPosix2(config));
|
|
5752
5934
|
return configs.flatMap((relativePath) => {
|
|
5753
|
-
const configPath = (0,
|
|
5935
|
+
const configPath = (0, import_node_path21.join)(workspaceRoot, relativePath);
|
|
5754
5936
|
if (!fileExists(configPath)) {
|
|
5755
5937
|
return [];
|
|
5756
5938
|
}
|
|
@@ -5784,7 +5966,7 @@ function checkDeclarationSpecifiers(workspaceRoot) {
|
|
|
5784
5966
|
});
|
|
5785
5967
|
}
|
|
5786
5968
|
function collectFindings(workspaceRoot) {
|
|
5787
|
-
const nxJsonPath = (0,
|
|
5969
|
+
const nxJsonPath = (0, import_node_path21.join)(workspaceRoot, "nx.json");
|
|
5788
5970
|
if (!fileExists(nxJsonPath)) {
|
|
5789
5971
|
throw new Error(
|
|
5790
5972
|
`No nx.json found in ${workspaceRoot} \u2014 run 'mnci doctor' from the workspace root.`
|
|
@@ -5829,8 +6011,8 @@ function runDoctor(workspaceRoot) {
|
|
|
5829
6011
|
}
|
|
5830
6012
|
|
|
5831
6013
|
// src/workspace-creation/adopt-directory.use-case.ts
|
|
5832
|
-
var
|
|
5833
|
-
var
|
|
6014
|
+
var import_node_fs15 = require("fs");
|
|
6015
|
+
var import_node_path22 = require("path");
|
|
5834
6016
|
var NEVER_COPIED = /* @__PURE__ */ new Set([".git", "node_modules"]);
|
|
5835
6017
|
var AGENT_AND_CI_ENTRIES = [
|
|
5836
6018
|
"AGENTS.md",
|
|
@@ -5861,13 +6043,13 @@ var PREFLIGHT_BLOCKERS = [
|
|
|
5861
6043
|
"packages"
|
|
5862
6044
|
];
|
|
5863
6045
|
function assertAdoptableDirectory(target) {
|
|
5864
|
-
if (!(0,
|
|
6046
|
+
if (!(0, import_node_fs15.existsSync)(target)) {
|
|
5865
6047
|
throw new Error(`--into '${target}' does not exist. Create or clone it first.`);
|
|
5866
6048
|
}
|
|
5867
|
-
if (!(0,
|
|
6049
|
+
if (!(0, import_node_fs15.statSync)(target).isDirectory()) {
|
|
5868
6050
|
throw new Error(`--into '${target}' is not a directory.`);
|
|
5869
6051
|
}
|
|
5870
|
-
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)));
|
|
5871
6053
|
if (blockers.length > 0) {
|
|
5872
6054
|
throw new Error(
|
|
5873
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.`
|
|
@@ -5875,15 +6057,15 @@ function assertAdoptableDirectory(target) {
|
|
|
5875
6057
|
}
|
|
5876
6058
|
}
|
|
5877
6059
|
function mergeGitignore(generatedFile, targetFile) {
|
|
5878
|
-
const existing = (0,
|
|
6060
|
+
const existing = (0, import_node_fs15.readFileSync)(targetFile, "utf8");
|
|
5879
6061
|
const present = new Set(existing.split("\n").map((line) => line.trim()));
|
|
5880
|
-
const additions = (0,
|
|
6062
|
+
const additions = (0, import_node_fs15.readFileSync)(generatedFile, "utf8").split("\n").map((line) => line.trimEnd()).filter((line) => {
|
|
5881
6063
|
const trimmed = line.trim();
|
|
5882
6064
|
return trimmed !== "" && !trimmed.startsWith("#") && !present.has(trimmed);
|
|
5883
6065
|
});
|
|
5884
6066
|
if (additions.length === 0) return false;
|
|
5885
6067
|
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
5886
|
-
(0,
|
|
6068
|
+
(0, import_node_fs15.writeFileSync)(
|
|
5887
6069
|
targetFile,
|
|
5888
6070
|
`${existing}${separator}
|
|
5889
6071
|
# Added by mnci (Nx workspace)
|
|
@@ -5893,9 +6075,9 @@ ${additions.join("\n")}
|
|
|
5893
6075
|
return true;
|
|
5894
6076
|
}
|
|
5895
6077
|
function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
5896
|
-
const entries = (0,
|
|
6078
|
+
const entries = (0, import_node_fs15.readdirSync)(generatedRoot).filter((entry) => !NEVER_COPIED.has(entry));
|
|
5897
6079
|
const collisions = entries.filter(
|
|
5898
|
-
(entry) => (0,
|
|
6080
|
+
(entry) => (0, import_node_fs15.existsSync)((0, import_node_path22.join)(target, entry)) && !EXISTING_WINS.has(entry) && entry !== ".gitignore"
|
|
5899
6081
|
);
|
|
5900
6082
|
if (collisions.length > 0) {
|
|
5901
6083
|
throw new Error(
|
|
@@ -5904,28 +6086,28 @@ function adoptGeneratedWorkspace(generatedRoot, target) {
|
|
|
5904
6086
|
}
|
|
5905
6087
|
const result = { copied: [], kept: [], mergedGitignore: false };
|
|
5906
6088
|
for (const entry of entries) {
|
|
5907
|
-
const from = (0,
|
|
5908
|
-
const to = (0,
|
|
5909
|
-
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)) {
|
|
5910
6092
|
result.mergedGitignore = mergeGitignore(from, to);
|
|
5911
6093
|
result.kept.push(entry);
|
|
5912
6094
|
continue;
|
|
5913
6095
|
}
|
|
5914
|
-
if ((0,
|
|
6096
|
+
if ((0, import_node_fs15.existsSync)(to)) {
|
|
5915
6097
|
result.kept.push(entry);
|
|
5916
6098
|
continue;
|
|
5917
6099
|
}
|
|
5918
|
-
(0,
|
|
6100
|
+
(0, import_node_fs15.cpSync)(from, to, { recursive: true });
|
|
5919
6101
|
result.copied.push(entry);
|
|
5920
6102
|
}
|
|
5921
|
-
(0,
|
|
6103
|
+
(0, import_node_fs15.rmSync)(generatedRoot, { recursive: true, force: true });
|
|
5922
6104
|
return result;
|
|
5923
6105
|
}
|
|
5924
6106
|
|
|
5925
6107
|
// src/workspace-creation/create-workspace.use-case.ts
|
|
5926
|
-
var
|
|
6108
|
+
var import_node_fs16 = require("fs");
|
|
5927
6109
|
var import_node_os = require("os");
|
|
5928
|
-
var
|
|
6110
|
+
var import_node_path23 = require("path");
|
|
5929
6111
|
function nxCloudProviderValue(ci) {
|
|
5930
6112
|
return ci === "azure" ? "azure" : "github";
|
|
5931
6113
|
}
|
|
@@ -5961,9 +6143,9 @@ async function resolveRegistry(options) {
|
|
|
5961
6143
|
return await promptRegistry();
|
|
5962
6144
|
}
|
|
5963
6145
|
async function runNew(name, options) {
|
|
5964
|
-
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);
|
|
5965
6147
|
if (adoptTarget !== void 0) assertAdoptableDirectory(adoptTarget);
|
|
5966
|
-
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));
|
|
5967
6149
|
assertValidProjectName(workspaceName, "Workspace name");
|
|
5968
6150
|
const scope = options.scope ?? (options.yes ? `@${workspaceName}` : await promptText("npm scope for publishable packages", `@${workspaceName}`));
|
|
5969
6151
|
const registry = await resolveRegistry(options);
|
|
@@ -5976,8 +6158,8 @@ async function runNew(name, options) {
|
|
|
5976
6158
|
const npmAuth = resolveNpmAuth(options.npmAuth, registry, ci);
|
|
5977
6159
|
const stack = await resolveStack(options);
|
|
5978
6160
|
const nxCloud = options.nxCloud ?? (options.yes ? false : await promptNxCloud());
|
|
5979
|
-
const stagingParent = adoptTarget === void 0 ? process.cwd() : (0,
|
|
5980
|
-
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);
|
|
5981
6163
|
try {
|
|
5982
6164
|
logger.step(`Creating Nx workspace '${workspaceName}' (preset: ts)`);
|
|
5983
6165
|
runNpx(
|
|
@@ -6000,7 +6182,7 @@ async function runNew(name, options) {
|
|
|
6000
6182
|
workspaceRoot = adoptTarget;
|
|
6001
6183
|
}
|
|
6002
6184
|
} finally {
|
|
6003
|
-
if (adoptTarget !== void 0) (0,
|
|
6185
|
+
if (adoptTarget !== void 0) (0, import_node_fs16.rmSync)(stagingParent, { recursive: true, force: true });
|
|
6004
6186
|
}
|
|
6005
6187
|
logger.step(
|
|
6006
6188
|
"Applying MoNecromanCI overlay (VS Code workspace, release config, .npmrc, commitlint, pipeline, stack)"
|
|
@@ -6010,8 +6192,8 @@ async function runNew(name, options) {
|
|
|
6010
6192
|
{ workspaceName, scope, registry, agent, variableGroup, ci, stack, ...npmAuth && { npmAuth } },
|
|
6011
6193
|
logger.detail
|
|
6012
6194
|
);
|
|
6013
|
-
(0,
|
|
6014
|
-
(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 });
|
|
6015
6197
|
logger.step("Installing the toolchain (commitlint + husky + linting/formatting)");
|
|
6016
6198
|
const installStatus = runShell(
|
|
6017
6199
|
"npm",
|
|
@@ -6042,12 +6224,12 @@ async function runNew(name, options) {
|
|
|
6042
6224
|
}
|
|
6043
6225
|
|
|
6044
6226
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
6045
|
-
var
|
|
6227
|
+
var import_node_path25 = require("path");
|
|
6046
6228
|
var import_prompts4 = require("@inquirer/prompts");
|
|
6047
6229
|
|
|
6048
6230
|
// src/workspace-upgrade/upgrade-workspace.use-case.ts
|
|
6049
|
-
var
|
|
6050
|
-
var
|
|
6231
|
+
var import_node_fs17 = require("fs");
|
|
6232
|
+
var import_node_path24 = require("path");
|
|
6051
6233
|
function resolveRegistry2(options, persisted) {
|
|
6052
6234
|
if (options.registry === "azure-artifacts" || options.organization && options.artifactsFeed) {
|
|
6053
6235
|
const persistedAzure = persisted?.kind === "azure-artifacts" ? persisted : void 0;
|
|
@@ -6076,7 +6258,7 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
6076
6258
|
return persisted.workspaceName;
|
|
6077
6259
|
}
|
|
6078
6260
|
try {
|
|
6079
|
-
const existing = (0,
|
|
6261
|
+
const existing = (0, import_node_fs17.readdirSync)(workspaceRoot).find(
|
|
6080
6262
|
(file) => file.endsWith(".code-workspace") && file !== "undefined.code-workspace"
|
|
6081
6263
|
);
|
|
6082
6264
|
if (existing) {
|
|
@@ -6084,11 +6266,11 @@ function resolveWorkspaceName(workspaceRoot, persisted) {
|
|
|
6084
6266
|
}
|
|
6085
6267
|
} catch {
|
|
6086
6268
|
}
|
|
6087
|
-
return (0,
|
|
6269
|
+
return (0, import_node_path24.basename)(workspaceRoot);
|
|
6088
6270
|
}
|
|
6089
6271
|
function detectNpmAuth(workspaceRoot) {
|
|
6090
6272
|
try {
|
|
6091
|
-
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;
|
|
6092
6274
|
} catch {
|
|
6093
6275
|
return void 0;
|
|
6094
6276
|
}
|
|
@@ -6135,7 +6317,7 @@ function resolveOverlayOptions(workspaceRoot, options, persisted) {
|
|
|
6135
6317
|
};
|
|
6136
6318
|
}
|
|
6137
6319
|
function runUpgrade(workspaceRoot, options) {
|
|
6138
|
-
if (!fileExists((0,
|
|
6320
|
+
if (!fileExists((0, import_node_path24.join)(workspaceRoot, "nx.json"))) {
|
|
6139
6321
|
throw new Error(
|
|
6140
6322
|
`No nx.json found in ${workspaceRoot} \u2014 this does not look like an Nx workspace. Run 'mnci upgrade' from the workspace root.`
|
|
6141
6323
|
);
|
|
@@ -6176,6 +6358,10 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
6176
6358
|
logger.step("Updating the VS Code extension packaging script");
|
|
6177
6359
|
logger.detail(`updated ${VSCODE_EXTENSION_SCRIPT_PATH}`);
|
|
6178
6360
|
}
|
|
6361
|
+
if (refreshGoReleaseScript(workspaceRoot)) {
|
|
6362
|
+
logger.step("Updating the releasable Go app script");
|
|
6363
|
+
logger.detail(`updated ${GO_RELEASE_SCRIPT_PATH}`);
|
|
6364
|
+
}
|
|
6179
6365
|
const upgradedDtsPlugins = upgradeDeclarationSpecifierPlugins(workspaceRoot);
|
|
6180
6366
|
if (upgradedDtsPlugins.length > 0) {
|
|
6181
6367
|
logger.step("Upgrading declaration specifiers to resolve under nodenext");
|
|
@@ -6192,7 +6378,7 @@ function runUpgrade(workspaceRoot, options) {
|
|
|
6192
6378
|
|
|
6193
6379
|
// src/workspace-creation/interactive-wizard.use-case.ts
|
|
6194
6380
|
async function runInteractive() {
|
|
6195
|
-
const inWorkspace = fileExists((0,
|
|
6381
|
+
const inWorkspace = fileExists((0, import_node_path25.join)(process.cwd(), "nx.json"));
|
|
6196
6382
|
const choiceNew = { name: "Create a new monorepo", value: "new" };
|
|
6197
6383
|
const choiceAdd = { name: "Add a project to this workspace", value: "add" };
|
|
6198
6384
|
const choiceUpgrade = {
|
|
@@ -6213,8 +6399,8 @@ async function runInteractive() {
|
|
|
6213
6399
|
}
|
|
6214
6400
|
|
|
6215
6401
|
// src/cli-version/check-for-update.use-case.ts
|
|
6216
|
-
var
|
|
6217
|
-
var
|
|
6402
|
+
var import_node_fs18 = require("fs");
|
|
6403
|
+
var import_node_path26 = require("path");
|
|
6218
6404
|
var import_cross_spawn2 = __toESM(require("cross-spawn"));
|
|
6219
6405
|
var PACKAGE_NAME = "@mnci/cli";
|
|
6220
6406
|
var REGISTRY_TIMEOUT_MS = 2e3;
|
|
@@ -6270,8 +6456,8 @@ function releaseTriple(version) {
|
|
|
6270
6456
|
}
|
|
6271
6457
|
function readCliVersion(packageDirectory) {
|
|
6272
6458
|
try {
|
|
6273
|
-
const manifestPath = (0,
|
|
6274
|
-
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"));
|
|
6275
6461
|
return manifest.version ?? "0.0.0";
|
|
6276
6462
|
} catch {
|
|
6277
6463
|
return "0.0.0";
|
|
@@ -6332,6 +6518,9 @@ function buildProgram(cliVersion) {
|
|
|
6332
6518
|
).option(
|
|
6333
6519
|
"--sidecar <go-app>",
|
|
6334
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"
|
|
6335
6524
|
).action(
|
|
6336
6525
|
async (kind, name, options) => {
|
|
6337
6526
|
await runAdd(kind, name, options);
|