nl-d365boilerplate-vite 1.0.1 ā 1.0.3
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/bin/cli.js +86 -67
- package/getToken.js +2 -4
- package/package.json +6 -1
package/bin/cli.js
CHANGED
|
@@ -1,84 +1,103 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { fileURLToPath } from "url";
|
|
6
|
+
import { intro, outro, text, isCancel, cancel } from "@clack/prompts";
|
|
6
7
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
9
|
const __dirname = path.dirname(__filename);
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
async function main() {
|
|
12
|
+
intro(`š Create NL D365 Boilerplate`);
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
console.error("Please specify the project directory:");
|
|
14
|
-
console.error(" npm create nl-d365boilerplate-vite <project-directory>");
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const targetPath = path.join(process.cwd(), targetDirName);
|
|
19
|
-
const templatePath = path.join(__dirname, "..");
|
|
14
|
+
let targetDirName = process.argv[2];
|
|
20
15
|
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
if (!targetDirName) {
|
|
17
|
+
const projectName = await text({
|
|
18
|
+
message: "What is the name of your project?",
|
|
19
|
+
placeholder: "my-d365-app",
|
|
20
|
+
validate(value) {
|
|
21
|
+
if (value.length === 0) return "Value is required!";
|
|
22
|
+
},
|
|
23
|
+
});
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const SKIP_FILES = [
|
|
30
|
-
"node_modules",
|
|
31
|
-
".git",
|
|
32
|
-
".env",
|
|
33
|
-
"package-lock.json",
|
|
34
|
-
"bin",
|
|
35
|
-
"dist",
|
|
36
|
-
".npmignore",
|
|
37
|
-
".DS_Store",
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
function copyDir(src, dest) {
|
|
41
|
-
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
42
|
-
|
|
43
|
-
for (const entry of entries) {
|
|
44
|
-
const srcPath = path.join(src, entry.name);
|
|
45
|
-
const destPath = path.join(dest, entry.name);
|
|
46
|
-
|
|
47
|
-
if (SKIP_FILES.includes(entry.name)) {
|
|
48
|
-
continue;
|
|
25
|
+
if (isCancel(projectName)) {
|
|
26
|
+
cancel("Operation cancelled.");
|
|
27
|
+
process.exit(0);
|
|
49
28
|
}
|
|
50
29
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
30
|
+
targetDirName = projectName;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const targetPath = path.join(process.cwd(), targetDirName);
|
|
34
|
+
const templatePath = path.join(__dirname, "..");
|
|
35
|
+
|
|
36
|
+
if (fs.existsSync(targetPath)) {
|
|
37
|
+
console.error(`\nā Directory "${targetDirName}" already exists.`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log(`\nCreating a new app in ${targetPath}...`);
|
|
42
|
+
fs.mkdirSync(targetPath, { recursive: true });
|
|
43
|
+
|
|
44
|
+
const SKIP_FILES = [
|
|
45
|
+
"node_modules",
|
|
46
|
+
".git",
|
|
47
|
+
".env",
|
|
48
|
+
"package-lock.json",
|
|
49
|
+
"bin",
|
|
50
|
+
"dist",
|
|
51
|
+
".npmignore",
|
|
52
|
+
".DS_Store",
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
function copyDir(src, dest) {
|
|
56
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
57
|
+
|
|
58
|
+
for (const entry of entries) {
|
|
59
|
+
const srcPath = path.join(src, entry.name);
|
|
60
|
+
const destPath = path.join(dest, entry.name);
|
|
61
|
+
|
|
62
|
+
if (SKIP_FILES.includes(entry.name)) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Prevent copying the new project directory into itself
|
|
67
|
+
if (path.resolve(srcPath) === path.resolve(targetPath)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (entry.isDirectory()) {
|
|
72
|
+
fs.mkdirSync(destPath, { recursive: true });
|
|
73
|
+
copyDir(srcPath, destPath);
|
|
74
|
+
} else {
|
|
75
|
+
fs.copyFileSync(srcPath, destPath);
|
|
76
|
+
}
|
|
56
77
|
}
|
|
57
78
|
}
|
|
79
|
+
|
|
80
|
+
// Copy files
|
|
81
|
+
copyDir(templatePath, targetPath);
|
|
82
|
+
|
|
83
|
+
// Update package.json
|
|
84
|
+
const pkgJsonPath = path.join(targetPath, "package.json");
|
|
85
|
+
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
86
|
+
|
|
87
|
+
pkg.name = targetDirName;
|
|
88
|
+
pkg.version = "0.0.0";
|
|
89
|
+
pkg.private = true;
|
|
90
|
+
delete pkg.bin;
|
|
91
|
+
delete pkg.files;
|
|
92
|
+
|
|
93
|
+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2));
|
|
94
|
+
|
|
95
|
+
outro(`You're all set!`);
|
|
96
|
+
|
|
97
|
+
console.log(`Next steps:`);
|
|
98
|
+
console.log(` cd ${targetDirName}`);
|
|
99
|
+
console.log(` npm install`);
|
|
100
|
+
console.log(` npm run dev`);
|
|
58
101
|
}
|
|
59
102
|
|
|
60
|
-
|
|
61
|
-
copyDir(templatePath, targetPath);
|
|
62
|
-
|
|
63
|
-
// Update package.json
|
|
64
|
-
const pkgJsonPath = path.join(targetPath, "package.json");
|
|
65
|
-
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
66
|
-
|
|
67
|
-
pkg.name = targetDirName;
|
|
68
|
-
pkg.version = "0.0.0";
|
|
69
|
-
pkg.private = true;
|
|
70
|
-
delete pkg.bin;
|
|
71
|
-
delete pkg.files;
|
|
72
|
-
|
|
73
|
-
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2));
|
|
74
|
-
|
|
75
|
-
console.log("\nSuccess! Created project at " + targetPath);
|
|
76
|
-
console.log("Inside that directory, you can run several commands:\n");
|
|
77
|
-
console.log(" npm install");
|
|
78
|
-
console.log(" Installs dependencies.\n");
|
|
79
|
-
console.log(" npm run dev");
|
|
80
|
-
console.log(" Starts the development server.\n");
|
|
81
|
-
console.log("\nWe suggest that you begin by typing:\n");
|
|
82
|
-
console.log(` cd ${targetDirName}`);
|
|
83
|
-
console.log(" npm install");
|
|
84
|
-
console.log(" npm run dev");
|
|
103
|
+
main().catch(console.error);
|
package/getToken.js
CHANGED
|
@@ -79,11 +79,9 @@ async function ensureClientId() {
|
|
|
79
79
|
|
|
80
80
|
if (!clientId) {
|
|
81
81
|
console.log(
|
|
82
|
-
"š CLIENT_ID required - find it in Azure Portal > App Registrations",
|
|
83
|
-
);
|
|
84
|
-
clientId = await promptUser(
|
|
85
|
-
"Enter your Azure App Registration Client ID: ",
|
|
82
|
+
"š CLIENT_ID required - find it in Azure Portal > App Registrations OR REST Builder export postman collection",
|
|
86
83
|
);
|
|
84
|
+
clientId = await promptUser("Enter your Client ID: ");
|
|
87
85
|
|
|
88
86
|
if (!clientId) {
|
|
89
87
|
throw new Error("CLIENT_ID is required for OAuth authentication");
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nl-d365boilerplate-vite",
|
|
3
|
+
"repository": {
|
|
4
|
+
"type": "git",
|
|
5
|
+
"url": "git+https://github.com/sj-cardoso/nl-d365boilerplate-vite.git"
|
|
6
|
+
},
|
|
3
7
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
8
|
+
"version": "1.0.3",
|
|
5
9
|
"type": "module",
|
|
6
10
|
"bin": {
|
|
7
11
|
"nl-d365boilerplate-vite": "./bin/cli.js"
|
|
@@ -31,6 +35,7 @@
|
|
|
31
35
|
"lint:fix": "eslint . --fix"
|
|
32
36
|
},
|
|
33
37
|
"dependencies": {
|
|
38
|
+
"@clack/prompts": "^0.11.0",
|
|
34
39
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
35
40
|
"@radix-ui/react-label": "^2.1.8",
|
|
36
41
|
"@radix-ui/react-separator": "^1.1.8",
|