@unisphere/nx 3.4.0 → 3.4.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"add-env-to-application-gitignore.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-0-0/add-env-to-application-gitignore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAC;AAsDpD,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAkF9D"}
1
+ {"version":3,"file":"add-env-to-application-gitignore.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-0-0/add-env-to-application-gitignore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,YAAY,CAAC;AAE1C,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA6B9D"}
@@ -2,116 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = update;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- const ENV_GITIGNORE_ENTRIES = `.env`;
7
- /**
8
- * Add .env entries to .gitignore for a given element
9
- * Returns: 'updated' | 'created' | 'skipped'
10
- */
11
- function addEnvToGitignore(tree, elementName, elementPath) {
12
- const gitignorePath = (0, path_1.join)(elementPath, '.gitignore');
13
- if (tree.exists(gitignorePath)) {
14
- // Read existing .gitignore
15
- const existingContent = tree.read(gitignorePath, 'utf-8') || '';
16
- // Check if .env is already in gitignore
17
- if (existingContent.includes('.env')) {
18
- devkit_1.logger.info(` ✅ ${elementName}: .gitignore already contains .env`);
19
- return 'skipped';
20
- }
21
- // Append .env entries to existing .gitignore
22
- const newContent = existingContent.trimEnd() + '\n\n# Environment files\n' + ENV_GITIGNORE_ENTRIES + '\n';
23
- tree.write(gitignorePath, newContent);
24
- devkit_1.logger.info(` ✅ ${elementName}: Added .env to existing .gitignore`);
25
- return 'updated';
26
- }
27
- else {
28
- // Create new .gitignore with .env entries
29
- const newContent = '# Environment files\n' + ENV_GITIGNORE_ENTRIES + '\n';
30
- tree.write(gitignorePath, newContent);
31
- devkit_1.logger.info(` ✅ ${elementName}: Created .gitignore with .env`);
32
- return 'created';
33
- }
34
- }
35
5
  async function update(tree) {
36
- devkit_1.logger.info('🔄 Adding .env to .gitignore files for all elements');
6
+ devkit_1.logger.info('🔄 Updating .gitignore to add migration-related entries...');
7
+ const gitignorePath = '.gitignore';
8
+ if (!tree.exists(gitignorePath)) {
9
+ devkit_1.logger.warn('⚠️ .gitignore file not found, creating one');
10
+ tree.write(gitignorePath, '');
11
+ }
37
12
  try {
38
- // Read .unisphere config
39
- if (!tree.exists('.unisphere')) {
40
- devkit_1.logger.warn('⚠️ No .unisphere file found, skipping');
41
- return;
42
- }
43
- const unisphereConfig = (0, devkit_1.readJson)(tree, '.unisphere');
44
- const elements = unisphereConfig.elements;
45
- if (!elements) {
46
- devkit_1.logger.info('ℹ️ No elements found, skipping');
47
- return;
48
- }
49
- let totalUpdated = 0;
50
- let totalCreated = 0;
51
- // Process applications
52
- const applications = elements.applications || {};
53
- if (Object.keys(applications).length > 0) {
54
- devkit_1.logger.info('\n📦 Processing applications...');
55
- for (const [name, config] of Object.entries(applications)) {
56
- const result = addEnvToGitignore(tree, name, config.sourceRoot);
57
- if (result === 'updated')
58
- totalUpdated++;
59
- if (result === 'created')
60
- totalCreated++;
61
- }
62
- }
63
- // Process packages
64
- const packages = elements.packages || {};
65
- if (Object.keys(packages).length > 0) {
66
- devkit_1.logger.info('\n📦 Processing packages...');
67
- for (const [name, config] of Object.entries(packages)) {
68
- const result = addEnvToGitignore(tree, name, config.sourceRoot);
69
- if (result === 'updated')
70
- totalUpdated++;
71
- if (result === 'created')
72
- totalCreated++;
73
- }
74
- }
75
- // Process runtimes
76
- const runtimes = elements.runtimes || {};
77
- if (Object.keys(runtimes).length > 0) {
78
- devkit_1.logger.info('\n📦 Processing runtimes...');
79
- for (const [name, config] of Object.entries(runtimes)) {
80
- const result = addEnvToGitignore(tree, name, config.sourceRoot);
81
- if (result === 'updated')
82
- totalUpdated++;
83
- if (result === 'created')
84
- totalCreated++;
85
- }
86
- }
87
- // Process workspace elements
88
- const workspace = elements.workspace || {};
89
- if (Object.keys(workspace).length > 0) {
90
- devkit_1.logger.info('\n📦 Processing workspace elements...');
91
- for (const [name, config] of Object.entries(workspace)) {
92
- const result = addEnvToGitignore(tree, name, config.sourceRoot);
93
- if (result === 'updated')
94
- totalUpdated++;
95
- if (result === 'created')
96
- totalCreated++;
97
- }
98
- }
99
- // Process loader elements
100
- const loader = elements.loader || {};
101
- if (Object.keys(loader).length > 0) {
102
- devkit_1.logger.info('\n📦 Processing loader elements...');
103
- for (const [name, config] of Object.entries(loader)) {
104
- const result = addEnvToGitignore(tree, name, config.sourceRoot);
105
- if (result === 'updated')
106
- totalUpdated++;
107
- if (result === 'created')
108
- totalCreated++;
109
- }
13
+ const currentContent = tree.read(gitignorePath, 'utf-8') || '';
14
+ let updatedContent = currentContent;
15
+ // Check if migrations.json is already in .gitignore
16
+ const migrationsJsonRegex = /^\.env$/gm;
17
+ if (!migrationsJsonRegex.test(updatedContent)) {
18
+ updatedContent += '.env\n';
19
+ tree.write(gitignorePath, updatedContent);
20
+ devkit_1.logger.info(`✅ Successfully updated .gitignore (added .env entry)`);
21
+ }
22
+ else {
23
+ devkit_1.logger.info('ℹ️ .env entry already exists in .gitignore');
110
24
  }
111
- devkit_1.logger.info(`\n✅ Done: ${totalUpdated} updated, ${totalCreated} created`);
112
25
  }
113
26
  catch (error) {
114
- devkit_1.logger.error(`❌ Failed to update .gitignore files: ${error?.message || 'Unknown error'}`);
115
- throw error;
27
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
28
+ devkit_1.logger.error(`❌ Failed to update .gitignore: ${errorMessage}`);
29
+ throw new Error(`Failed to update .gitignore: ${errorMessage}`);
116
30
  }
117
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisphere/nx",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",