@interopio/iocd-cli 0.0.19 โ†’ 0.0.21

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.
@@ -0,0 +1,23 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /.pnp
6
+ .pnp.js
7
+
8
+ # testing
9
+ /coverage
10
+
11
+ # production
12
+ /build
13
+
14
+ # misc
15
+ .DS_Store
16
+ .env.local
17
+ .env.development.local
18
+ .env.test.local
19
+ .env.production.local
20
+
21
+ npm-debug.log*
22
+ yarn-debug.log*
23
+ yarn-error.log*
@@ -0,0 +1,6 @@
1
+ config/iocd.license.key
2
+ temp/
3
+ dist/
4
+ node_modules/
5
+ components/
6
+ .DS_store
@@ -0,0 +1 @@
1
+ public/modals-ui/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/iocd-cli",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "CLI tool for setting up, building and packaging io.Connect Desktop platforms",
5
5
  "engines": {
6
6
  "node": ">=18.0.0",
@@ -22,7 +22,12 @@
22
22
  "lint": "eslint src --ext .ts",
23
23
  "lint:fix": "eslint src --ext .ts --fix",
24
24
  "format": "prettier --write src/**/*.ts",
25
- "prepublishOnly": "npm run build",
25
+ "prepublishOnly": "npm run build && npm run gitignore:pre-package",
26
+ "postpublish": "npm run gitignore:post-publish",
27
+ "postinstall": "npm run gitignore:post-install",
28
+ "gitignore:pre-package": "node ./scripts/handle-gitignore-templates.js pre-package",
29
+ "gitignore:post-publish": "node ./scripts/handle-gitignore-templates.js post-publish",
30
+ "gitignore:post-install": "node ./scripts/handle-gitignore-templates.js post-install",
26
31
  "cli": "npm run build && node dist/cli.js"
27
32
  },
28
33
  "keywords": [
@@ -36,7 +41,7 @@
36
41
  "license": "MIT",
37
42
  "files": [
38
43
  "dist",
39
- "templates",
44
+ "scripts",
40
45
  "tools",
41
46
  "README.md"
42
47
  ],
@@ -0,0 +1,16 @@
1
+ const { cp } = require("fs/promises");
2
+
3
+ async function main() {
4
+ console.log("Copying template files...");
5
+ await cp("src/templates", "dist/templates", { recursive: true });
6
+ console.log("Template files copied successfully");
7
+
8
+ console.log("Copying tools files...");
9
+ await cp("tools", "dist/tools", { recursive: true });
10
+ console.log("Tools copied successfully");
11
+ }
12
+
13
+ main().catch(err => {
14
+ console.error(err);
15
+ process.exit(1);
16
+ });
@@ -0,0 +1,13 @@
1
+ // delete the dist folder before a new build
2
+ const { rm } = require("fs/promises");
3
+
4
+ async function main() {
5
+ console.log("Deleting dist folder...");
6
+ await rm("dist", { recursive: true, force: true });
7
+ console.log("Dist folder deleted successfully");
8
+ }
9
+
10
+ main().catch(err => {
11
+ console.error(err);
12
+ process.exit(1);
13
+ });
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ /**
7
+ * Script to handle .gitignore template files for npm packaging
8
+ *
9
+ * Usage:
10
+ * - npm run pre-package: Copies .gitignore files to .gitignore.template
11
+ * - npm run post-publish: Removes .gitignore.template files
12
+ * - npm run post-install: Renames .gitignore.template back to .gitignore
13
+ */
14
+
15
+ const templatesDir = path.join(__dirname, '..', 'src', 'templates');
16
+ const distTemplatesDir = path.join(__dirname, '..', 'dist', 'templates');
17
+
18
+ function findGitignoreFiles(dir) {
19
+ const gitignoreFiles = [];
20
+
21
+ function walk(currentDir) {
22
+ if (!fs.existsSync(currentDir)) return;
23
+
24
+ const files = fs.readdirSync(currentDir);
25
+
26
+ for (const file of files) {
27
+ const filePath = path.join(currentDir, file);
28
+ const stat = fs.statSync(filePath);
29
+
30
+ if (stat.isDirectory()) {
31
+ walk(filePath);
32
+ } else if (file === '.gitignore') {
33
+ gitignoreFiles.push(filePath);
34
+ }
35
+ }
36
+ }
37
+
38
+ walk(dir);
39
+ return gitignoreFiles;
40
+ }
41
+
42
+ function findGitignoreTemplateFiles(dir) {
43
+ const templateFiles = [];
44
+
45
+ function walk(currentDir) {
46
+ if (!fs.existsSync(currentDir)) return;
47
+
48
+ const files = fs.readdirSync(currentDir);
49
+
50
+ for (const file of files) {
51
+ const filePath = path.join(currentDir, file);
52
+ const stat = fs.statSync(filePath);
53
+
54
+ if (stat.isDirectory()) {
55
+ walk(filePath);
56
+ } else if (file === '.gitignore.template') {
57
+ templateFiles.push(filePath);
58
+ }
59
+ }
60
+ }
61
+
62
+ walk(dir);
63
+ return templateFiles;
64
+ }
65
+
66
+ function copyGitignoreToTemplate() {
67
+ console.log('๐Ÿ“ฆ Pre-package: Converting .gitignore files to .gitignore.template files...');
68
+
69
+ // Handle both src and dist directories
70
+ const directories = [templatesDir, distTemplatesDir];
71
+ let totalFiles = 0;
72
+
73
+ for (const dir of directories) {
74
+ if (!fs.existsSync(dir)) continue;
75
+
76
+ const gitignoreFiles = findGitignoreFiles(dir);
77
+
78
+ for (const gitignoreFile of gitignoreFiles) {
79
+ const templateFile = gitignoreFile + '.template';
80
+
81
+ try {
82
+ fs.copyFileSync(gitignoreFile, templateFile);
83
+ console.log(`โœ… Copied: ${path.relative(process.cwd(), gitignoreFile)} โ†’ ${path.relative(process.cwd(), templateFile)}`);
84
+ totalFiles++;
85
+ } catch (error) {
86
+ console.error(`โŒ Failed to copy ${gitignoreFile}:`, error.message);
87
+ }
88
+ }
89
+ }
90
+
91
+ console.log(`๐Ÿ“ฆ Pre-package complete: ${totalFiles} .gitignore files converted to .template files`);
92
+ }
93
+
94
+ function removeTemplateFiles() {
95
+ console.log('๐Ÿงน Post-publish: Removing .gitignore.template files...');
96
+
97
+ // Handle both src and dist directories
98
+ const directories = [templatesDir, distTemplatesDir];
99
+ let totalFiles = 0;
100
+
101
+ for (const dir of directories) {
102
+ if (!fs.existsSync(dir)) continue;
103
+
104
+ const templateFiles = findGitignoreTemplateFiles(dir);
105
+
106
+ for (const templateFile of templateFiles) {
107
+ try {
108
+ fs.unlinkSync(templateFile);
109
+ console.log(`๐Ÿ—‘๏ธ Removed: ${path.relative(process.cwd(), templateFile)}`);
110
+ totalFiles++;
111
+ } catch (error) {
112
+ console.error(`โŒ Failed to remove ${templateFile}:`, error.message);
113
+ }
114
+ }
115
+ }
116
+
117
+ console.log(`๐Ÿงน Post-publish complete: ${totalFiles} .gitignore.template files removed`);
118
+ }
119
+
120
+ function convertTemplateToGitignore() {
121
+ console.log('๐Ÿ”„ Post-install: Converting .gitignore.template files back to .gitignore...');
122
+
123
+ // Only handle dist directory for post-install
124
+ const templateFiles = findGitignoreTemplateFiles(distTemplatesDir);
125
+ let totalFiles = 0;
126
+
127
+ for (const templateFile of templateFiles) {
128
+ const gitignoreFile = templateFile.replace('.template', '');
129
+
130
+ try {
131
+ fs.renameSync(templateFile, gitignoreFile);
132
+ console.log(`โœ… Converted: ${path.relative(process.cwd(), templateFile)} โ†’ ${path.relative(process.cwd(), gitignoreFile)}`);
133
+ totalFiles++;
134
+ } catch (error) {
135
+ console.error(`โŒ Failed to convert ${templateFile}:`, error.message);
136
+ }
137
+ }
138
+
139
+ console.log(`๐Ÿ”„ Post-install complete: ${totalFiles} .gitignore.template files converted back to .gitignore`);
140
+ }
141
+
142
+ // Parse command line arguments
143
+ const command = process.argv[2];
144
+
145
+ switch (command) {
146
+ case 'pre-package':
147
+ copyGitignoreToTemplate();
148
+ break;
149
+ case 'post-publish':
150
+ removeTemplateFiles();
151
+ break;
152
+ case 'post-install':
153
+ convertTemplateToGitignore();
154
+ break;
155
+ default:
156
+ console.error('Usage: node handle-gitignore-templates.js <pre-package|post-publish|post-install>');
157
+ process.exit(1);
158
+ }