@uns-kit/cli 0.0.19 → 0.0.22
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/dist/index.js +36 -5
- package/package.json +2 -2
- package/templates/default/gitignore +48 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
|
-
import { access,
|
|
3
|
+
import { access, mkdir, readFile, readdir, stat, writeFile, copyFile } from "node:fs/promises";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -12,6 +12,7 @@ import * as azdev from "azure-devops-node-api";
|
|
|
12
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
13
13
|
const __dirname = path.dirname(__filename);
|
|
14
14
|
const require = createRequire(import.meta.url);
|
|
15
|
+
const cliVersion = resolveCliVersion();
|
|
15
16
|
const coreVersion = resolveCoreVersion();
|
|
16
17
|
const execFileAsync = promisify(execFile);
|
|
17
18
|
const AZURE_DEVOPS_PROVIDER = "azure-devops";
|
|
@@ -120,7 +121,8 @@ async function main() {
|
|
|
120
121
|
process.exitCode = 1;
|
|
121
122
|
}
|
|
122
123
|
function printHelp() {
|
|
123
|
-
console.log(
|
|
124
|
+
console.log(`\nuns-kit v${cliVersion}\n` +
|
|
125
|
+
"\nUsage: uns-kit <command> [options]\n" +
|
|
124
126
|
"\nCommands:\n" +
|
|
125
127
|
" create <name> Scaffold a new UNS application\n" +
|
|
126
128
|
" configure-devops [dir] Configure Azure DevOps tooling in an existing project\n" +
|
|
@@ -136,7 +138,7 @@ async function createProject(projectName) {
|
|
|
136
138
|
const targetDir = path.resolve(process.cwd(), projectName);
|
|
137
139
|
await ensureTargetDir(targetDir);
|
|
138
140
|
const templateDir = path.resolve(__dirname, "../templates/default");
|
|
139
|
-
await
|
|
141
|
+
await copyTemplateDirectory(templateDir, targetDir, targetDir);
|
|
140
142
|
const pkgName = normalizePackageName(projectName);
|
|
141
143
|
await patchPackageJson(targetDir, pkgName);
|
|
142
144
|
await patchConfigJson(targetDir, pkgName);
|
|
@@ -455,8 +457,9 @@ async function copyTemplateDirectory(sourceDir, targetDir, targetRoot) {
|
|
|
455
457
|
const skipped = [];
|
|
456
458
|
for (const entry of entries) {
|
|
457
459
|
const sourcePath = path.join(sourceDir, entry.name);
|
|
458
|
-
const
|
|
459
|
-
const
|
|
460
|
+
const destinationName = entry.isFile() ? normalizeTemplateFilename(entry.name) : entry.name;
|
|
461
|
+
const destinationPath = path.join(targetDir, destinationName);
|
|
462
|
+
const relativePath = path.relative(targetRoot, destinationPath) || destinationName;
|
|
460
463
|
if (entry.isDirectory()) {
|
|
461
464
|
await mkdir(destinationPath, { recursive: true });
|
|
462
465
|
const result = await copyTemplateDirectory(sourcePath, destinationPath, targetRoot);
|
|
@@ -476,6 +479,12 @@ async function copyTemplateDirectory(sourceDir, targetDir, targetRoot) {
|
|
|
476
479
|
}
|
|
477
480
|
return { copied, skipped };
|
|
478
481
|
}
|
|
482
|
+
function normalizeTemplateFilename(filename) {
|
|
483
|
+
if (filename === "gitignore" || filename === ".npmignore") {
|
|
484
|
+
return ".gitignore";
|
|
485
|
+
}
|
|
486
|
+
return filename;
|
|
487
|
+
}
|
|
479
488
|
async function configurePlugin(options) {
|
|
480
489
|
const { targetPath, templateName, dependencyName, dependencySpecifier, label } = options;
|
|
481
490
|
const targetDir = path.resolve(process.cwd(), targetPath ?? ".");
|
|
@@ -872,6 +881,28 @@ function resolveUnsPackageVersion(packageName, relativeLocalPath) {
|
|
|
872
881
|
}
|
|
873
882
|
return "0.0.1";
|
|
874
883
|
}
|
|
884
|
+
function resolveCliVersion() {
|
|
885
|
+
const attempt = (factory) => {
|
|
886
|
+
try {
|
|
887
|
+
return factory();
|
|
888
|
+
}
|
|
889
|
+
catch (error) {
|
|
890
|
+
return undefined;
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
const packageVersion = attempt(() => {
|
|
894
|
+
const pkg = require("../package.json");
|
|
895
|
+
return pkg?.version;
|
|
896
|
+
});
|
|
897
|
+
if (packageVersion) {
|
|
898
|
+
return packageVersion;
|
|
899
|
+
}
|
|
900
|
+
const envVersion = attempt(() => process.env.npm_package_version?.trim());
|
|
901
|
+
if (envVersion) {
|
|
902
|
+
return envVersion;
|
|
903
|
+
}
|
|
904
|
+
return "0.0.0";
|
|
905
|
+
}
|
|
875
906
|
function resolveCoreVersion() {
|
|
876
907
|
const attempt = (factory) => {
|
|
877
908
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uns-kit/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "Command line scaffolding tool for UNS applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"azure-devops-node-api": "^15.1.1",
|
|
29
|
-
"@uns-kit/core": "0.0.
|
|
29
|
+
"@uns-kit/core": "0.0.24"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc -p tsconfig.build.json",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
.pnpm-store/
|
|
4
|
+
.pnpm/
|
|
5
|
+
.pnp.cjs
|
|
6
|
+
.pnp.loader.mjs
|
|
7
|
+
|
|
8
|
+
# Build outputs
|
|
9
|
+
build/
|
|
10
|
+
dist/
|
|
11
|
+
tmp/
|
|
12
|
+
temp/
|
|
13
|
+
*.tsbuildinfo
|
|
14
|
+
|
|
15
|
+
# Logs & diagnostics
|
|
16
|
+
logs/
|
|
17
|
+
*.log
|
|
18
|
+
npm-debug.log*
|
|
19
|
+
yarn-debug.log*
|
|
20
|
+
pnpm-debug.log*
|
|
21
|
+
lerna-debug.log*
|
|
22
|
+
|
|
23
|
+
# Test & coverage artifacts
|
|
24
|
+
coverage/
|
|
25
|
+
.nyc_output/
|
|
26
|
+
.vitest/
|
|
27
|
+
|
|
28
|
+
# Runtime queues & sandboxes
|
|
29
|
+
publisherQueue/
|
|
30
|
+
sandbox-*
|
|
31
|
+
tmp-rtt
|
|
32
|
+
.tmp-rtt
|
|
33
|
+
|
|
34
|
+
# Environment & secrets
|
|
35
|
+
.env
|
|
36
|
+
.env.*
|
|
37
|
+
!.env.example
|
|
38
|
+
!.env.sample
|
|
39
|
+
|
|
40
|
+
# Editor files & OS cruft
|
|
41
|
+
.idea/
|
|
42
|
+
.DS_Store
|
|
43
|
+
Thumbs.db
|
|
44
|
+
*.swp
|
|
45
|
+
*.swo
|
|
46
|
+
|
|
47
|
+
# Package managers
|
|
48
|
+
package-lock.json
|