@interopio/iocd-cli 0.0.38 โ 0.0.40
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 +780 -758
- package/dist/cli.js +0 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/setup.command.js +1 -7
- package/dist/commands/setup.command.js.map +1 -1
- package/dist/services/installer/electronForge.js +5 -3
- package/dist/services/installer/electronForge.js.map +1 -1
- package/dist/services/installer/macOS.helper.js +0 -1
- package/dist/services/installer/macOS.helper.js.map +1 -1
- package/dist/services/license.service.js +14 -14
- package/dist/templates/groups/apps/groups/.gitignore.template +23 -23
- package/dist/templates/groups/apps/groups/README.md +15 -15
- package/dist/templates/groups/apps/groups/config/web-group-dev.json +12 -12
- package/dist/templates/groups/apps/groups/index.html +17 -17
- package/dist/templates/groups/apps/groups/iocd.app.json +19 -19
- package/dist/templates/groups/apps/groups/package.json +25 -25
- package/dist/templates/groups/apps/groups/public/manifest.json +24 -24
- package/dist/templates/groups/apps/groups/public/robots.txt +3 -3
- package/dist/templates/groups/apps/groups/src/App.css +38 -38
- package/dist/templates/groups/apps/groups/src/App.tsx +11 -11
- package/dist/templates/groups/apps/groups/src/index.css +13 -13
- package/dist/templates/groups/apps/groups/src/index.tsx +19 -19
- package/dist/templates/groups/apps/groups/vite.config.ts +8 -8
- package/dist/templates/groups/template.json +12 -12
- package/dist/templates/ioconnect-desktop/.github/actions/setup-smctl/action.yml +121 -121
- package/dist/templates/ioconnect-desktop/.github/workflows/build.yml +395 -395
- package/dist/templates/ioconnect-desktop/.gitignore.template +15 -15
- package/dist/templates/ioconnect-desktop/README.md +780 -758
- package/dist/templates/ioconnect-desktop/config/forge.config.js +59 -59
- package/dist/templates/ioconnect-desktop/config/iocd.cli.config.json +16 -16
- package/dist/templates/ioconnect-desktop/config/mac-build/entitlements.mac.plist +44 -44
- package/dist/templates/ioconnect-desktop/config/win-build/template.nuspectemplate +32 -32
- package/dist/templates/ioconnect-desktop/modifications/base/iocd/config/system.json.merge +2 -2
- package/dist/templates/ioconnect-desktop/modifications/base/iocd/config/system.json.merge-autoUpdate +9 -9
- package/dist/templates/ioconnect-desktop/package.json +33 -32
- package/dist/templates/ioconnect-desktop/template.json +6 -6
- package/dist/templates/launchpad/apps/launchpad/.eslintrc.json +3 -3
- package/dist/templates/launchpad/apps/launchpad/.gitignore.template +1 -1
- package/dist/templates/launchpad/apps/launchpad/config/iocd.app.def.dev.json +56 -56
- package/dist/templates/launchpad/apps/launchpad/config/iocd.system.build.json +2 -2
- package/dist/templates/launchpad/apps/launchpad/config/iocd.system.dev.json +2 -2
- package/dist/templates/launchpad/apps/launchpad/index.html +16 -16
- package/dist/templates/launchpad/apps/launchpad/iocd.app.json +27 -27
- package/dist/templates/launchpad/apps/launchpad/package-lock.json +2778 -2778
- package/dist/templates/launchpad/apps/launchpad/package.json +21 -21
- package/dist/templates/launchpad/apps/launchpad/src/app/app.tsx +41 -41
- package/dist/templates/launchpad/apps/launchpad/src/app/constants.ts +27 -27
- package/dist/templates/launchpad/apps/launchpad/src/components/logo.tsx +11 -11
- package/dist/templates/launchpad/apps/launchpad/src/components/main-context-menu.tsx +161 -161
- package/dist/templates/launchpad/apps/launchpad/src/components/notifications-button.tsx +44 -44
- package/dist/templates/launchpad/apps/launchpad/src/main.tsx +6 -6
- package/dist/templates/launchpad/apps/launchpad/src/styles.css +16 -16
- package/dist/templates/launchpad/apps/launchpad/tsconfig.json +10 -10
- package/dist/templates/launchpad/apps/launchpad/vite.config.ts +13 -13
- package/dist/templates/launchpad/template.json +12 -12
- package/dist/templates/splash/apps/splash/assets/styles/style.css +39 -39
- package/dist/templates/splash/apps/splash/iocd.app.json +7 -7
- package/dist/templates/splash/apps/splash/script.js +53 -53
- package/dist/templates/splash/apps/splash/splash.html +25 -25
- package/dist/templates/splash/template.json +12 -12
- package/dist/templates/tests/template.json +8 -8
- package/dist/templates/tests/tests/package-lock.json +7289 -7289
- package/dist/templates/tests/tests/package.json +22 -22
- package/dist/templates/tests/tests/tests/sample.spec.ts +30 -30
- package/dist/templates/tests/tests/tsconfig.json +10 -10
- package/dist/templates/tests/tests/wdio.config.ts +32 -32
- package/dist/templates/workspaces/apps/workspaces/README.md +15 -15
- package/dist/templates/workspaces/apps/workspaces/config/workspaces-dev.json +20 -20
- package/dist/templates/workspaces/apps/workspaces/index.html +17 -17
- package/dist/templates/workspaces/apps/workspaces/iocd.app.json +19 -19
- package/dist/templates/workspaces/apps/workspaces/package.json +29 -29
- package/dist/templates/workspaces/apps/workspaces/public/manifest.json +25 -25
- package/dist/templates/workspaces/apps/workspaces/public/robots.txt +3 -3
- package/dist/templates/workspaces/apps/workspaces/src/App.css +38 -38
- package/dist/templates/workspaces/apps/workspaces/src/App.tsx +102 -102
- package/dist/templates/workspaces/apps/workspaces/src/index.css +3 -3
- package/dist/templates/workspaces/apps/workspaces/src/index.tsx +28 -28
- package/dist/templates/workspaces/apps/workspaces/src/logo.svg +7 -7
- package/dist/templates/workspaces/apps/workspaces/src/reportWebVitals.ts +15 -15
- package/dist/templates/workspaces/apps/workspaces/src/setupTests.ts +5 -5
- package/dist/templates/workspaces/apps/workspaces/vite.config.ts +8 -8
- package/dist/templates/workspaces/template.json +12 -12
- package/package.json +83 -83
- package/scripts/copy-assets.js +19 -19
- package/scripts/delete-dist.js +12 -12
- package/scripts/generate-schema.js +50 -50
- package/scripts/handle-gitignore-templates.js +157 -157
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { execSync } = require('child_process');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
|
|
7
|
-
console.log('Generating JSON schema from CliConfig interface...');
|
|
8
|
-
|
|
9
|
-
const schemaDir = path.join(__dirname, '..', 'dist', 'schemas');
|
|
10
|
-
const schemaFile = path.join(schemaDir, 'iocd.cli.config.schema.json');
|
|
11
|
-
|
|
12
|
-
// Ensure the schemas directory exists
|
|
13
|
-
if (!fs.existsSync(schemaDir)) {
|
|
14
|
-
fs.mkdirSync(schemaDir, { recursive: true });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
// Generate schema using typescript-json-schema
|
|
19
|
-
// Point directly to the source file to avoid compilation issues
|
|
20
|
-
execSync(
|
|
21
|
-
`npx typescript-json-schema ./src/services/config/cli.config.ts CliConfig --required --noExtraProps --out ${schemaFile}`,
|
|
22
|
-
{
|
|
23
|
-
cwd: path.join(__dirname, '..'),
|
|
24
|
-
stdio: 'inherit'
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// Read the generated schema
|
|
29
|
-
const schema = JSON.parse(fs.readFileSync(schemaFile, 'utf8'));
|
|
30
|
-
|
|
31
|
-
// Add metadata at the beginning, preserving proper order
|
|
32
|
-
const enhancedSchema = {
|
|
33
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
34
|
-
"$id": "https://unpkg.com/@interopio/iocd-cli/schemas/iocd.cli.config.schema.json",
|
|
35
|
-
"title": "io.Connect Desktop CLI Configuration",
|
|
36
|
-
"description": "Configuration schema for io.Connect Desktop CLI projects",
|
|
37
|
-
"additionalProperties": schema.additionalProperties,
|
|
38
|
-
"properties": schema.properties,
|
|
39
|
-
"required": schema.required,
|
|
40
|
-
"type": schema.type || "object"
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Write back the updated schema
|
|
44
|
-
fs.writeFileSync(schemaFile, JSON.stringify(enhancedSchema, null, 2));
|
|
45
|
-
|
|
46
|
-
console.log('โ
JSON schema generated successfully at:', schemaFile);
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error('โ Error generating JSON schema:', error.message);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
console.log('Generating JSON schema from CliConfig interface...');
|
|
8
|
+
|
|
9
|
+
const schemaDir = path.join(__dirname, '..', 'dist', 'schemas');
|
|
10
|
+
const schemaFile = path.join(schemaDir, 'iocd.cli.config.schema.json');
|
|
11
|
+
|
|
12
|
+
// Ensure the schemas directory exists
|
|
13
|
+
if (!fs.existsSync(schemaDir)) {
|
|
14
|
+
fs.mkdirSync(schemaDir, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// Generate schema using typescript-json-schema
|
|
19
|
+
// Point directly to the source file to avoid compilation issues
|
|
20
|
+
execSync(
|
|
21
|
+
`npx typescript-json-schema ./src/services/config/cli.config.ts CliConfig --required --noExtraProps --out ${schemaFile}`,
|
|
22
|
+
{
|
|
23
|
+
cwd: path.join(__dirname, '..'),
|
|
24
|
+
stdio: 'inherit'
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// Read the generated schema
|
|
29
|
+
const schema = JSON.parse(fs.readFileSync(schemaFile, 'utf8'));
|
|
30
|
+
|
|
31
|
+
// Add metadata at the beginning, preserving proper order
|
|
32
|
+
const enhancedSchema = {
|
|
33
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
34
|
+
"$id": "https://unpkg.com/@interopio/iocd-cli/schemas/iocd.cli.config.schema.json",
|
|
35
|
+
"title": "io.Connect Desktop CLI Configuration",
|
|
36
|
+
"description": "Configuration schema for io.Connect Desktop CLI projects",
|
|
37
|
+
"additionalProperties": schema.additionalProperties,
|
|
38
|
+
"properties": schema.properties,
|
|
39
|
+
"required": schema.required,
|
|
40
|
+
"type": schema.type || "object"
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Write back the updated schema
|
|
44
|
+
fs.writeFileSync(schemaFile, JSON.stringify(enhancedSchema, null, 2));
|
|
45
|
+
|
|
46
|
+
console.log('โ
JSON schema generated successfully at:', schemaFile);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('โ Error generating JSON schema:', error.message);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
@@ -1,158 +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);
|
|
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
158
|
}
|