@unisphere/nx 3.4.0 → 3.5.0

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
  }
@@ -0,0 +1,89 @@
1
+ name: CI/CD
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - 'prerelease/**'
8
+
9
+ permissions:
10
+ id-token: write
11
+ contents: write
12
+ packages: write
13
+
14
+ jobs:
15
+ release:
16
+ name: Release
17
+ runs-on:
18
+ - codebuild-ovp-unisphere-runner-${{ github.run_id }}-${{ github.attempt }}
19
+ - instance-size:medium
20
+ outputs:
21
+ hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
22
+ steps:
23
+
24
+ - name: Cache npm
25
+ uses: actions/cache@v3
26
+ with:
27
+ path: ~/.npm
28
+ key: dependencies-${{ runner.os }}-node-${{ hashFiles('.nvmrc') }}-${{ hashFiles('package-lock.json') }}
29
+ restore-keys: |
30
+ dependencies-${{ runner.os }}-node-${{ hashFiles('.nvmrc') }}-
31
+
32
+ - name: Checkout Repo
33
+ uses: actions/checkout@v4
34
+
35
+ - name: Check if part of prerelease or official release
36
+ id: check
37
+ run: |
38
+ if [ "${{ github.ref }}" = "refs/heads/main" ] && [ -f ".changeset/pre.json" ]; then
39
+ echo "main branch should not have pre.json file, skipping job"
40
+ exit 1
41
+ elif [[ "${{ github.ref }}" == "refs/heads/prerelease/"* ]] && [ ! -f ".changeset/pre.json" ]; then
42
+ echo "prerelease branch must have pre.json file, skipping job"
43
+ exit 1
44
+ elif [ "${{ github.ref }}" != "refs/heads/main" ] && [[ "${{ github.ref }}" != "refs/heads/prerelease/"* ]]; then
45
+ echo "not part of prerelease or official release, skipping job"
46
+ exit 1
47
+ fi
48
+
49
+ - name: Setup Node.js
50
+ uses: actions/setup-node@v4
51
+ with:
52
+ node-version-file: '.nvmrc'
53
+
54
+ - name: Pre-CICD Checks
55
+ uses: kaltura/unisphere-core/.github/actions/pre-cicd@main
56
+ with:
57
+ repo-path: '${{ github.workspace }}'
58
+
59
+ - name: Setup JFrog
60
+
61
+ uses: jfrog/setup-jfrog-cli@v4
62
+ id: setup-jfrog
63
+ env:
64
+ JF_URL: https://kalturaa.jfrog.io
65
+ with:
66
+ oidc-provider-name: ovp-github-oidc
67
+
68
+ - name: Install Dependencies
69
+ run: npm ci --prefer-offline --include=optional --no-fund
70
+ env:
71
+ GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72
+ KALTURA_JFROG_TOKEN: ${{ steps.setup-jfrog.outputs.oidc-token }}
73
+
74
+ - name: Create Release Pull Request or Publish to npm
75
+ id: changesets
76
+ uses: changesets/action@v1
77
+ env:
78
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79
+
80
+ - name: Create release tags
81
+ if: steps.changesets.outputs.hasChangesets == 'false'
82
+ run: |
83
+ npx changeset tag
84
+ git push --follow-tags
85
+
86
+ publish-artifacts:
87
+ needs: release
88
+ if: needs.release.outputs.hasChangesets == 'false'
89
+ uses: ./.github/workflows/_publish-artifacts.yml
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=update-cicd-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-cicd-workflow.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-5-0/update-cicd-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,YAAY,CAAC;AAI1C,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC9D"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ async function update(tree) {
8
+ devkit_1.logger.info('🔄 Updating GitHub CICD workflow for v3.5.0');
9
+ // Ensure .github/workflows directory exists
10
+ if (!tree.exists('.github')) {
11
+ tree.write('.github/.gitkeep', '');
12
+ devkit_1.logger.info('✅ Created .github directory');
13
+ }
14
+ if (!tree.exists('.github/workflows')) {
15
+ tree.write('.github/workflows/.gitkeep', '');
16
+ devkit_1.logger.info('✅ Created .github/workflows directory');
17
+ }
18
+ try {
19
+ // Update cicd.yml
20
+ const cicdWorkflowPath = '.github/workflows/cicd.yml';
21
+ const cicdTemplatePath = (0, path_1.join)(__dirname, 'templates', 'cicd.template');
22
+ const cicdTemplateContent = (0, fs_1.readFileSync)(cicdTemplatePath, 'utf-8');
23
+ const cicdExists = tree.exists(cicdWorkflowPath);
24
+ tree.write(cicdWorkflowPath, cicdTemplateContent);
25
+ if (cicdExists) {
26
+ devkit_1.logger.info(`✅ Updated ${cicdWorkflowPath}`);
27
+ }
28
+ else {
29
+ devkit_1.logger.info(`✅ Created ${cicdWorkflowPath}`);
30
+ }
31
+ }
32
+ catch (error) {
33
+ devkit_1.logger.error(`❌ Failed to update GitHub CICD workflow: ${error?.message || 'Unknown error'}`);
34
+ throw error;
35
+ }
36
+ }
package/migrations.json CHANGED
@@ -290,6 +290,14 @@
290
290
  "cli": {
291
291
  "postUpdateMessage": "✅ .gitignore updated to exclude .claude/settings.local.json"
292
292
  }
293
+ },
294
+ "3-5-0-update-cicd-workflow": {
295
+ "version": "3.5.0",
296
+ "description": "Updates .github/workflows/cicd.yml with JFrog OIDC setup and improved cache management",
297
+ "factory": "./dist/migrations/3-5-0/update-cicd-workflow.js",
298
+ "cli": {
299
+ "postUpdateMessage": "✅ .github/workflows/cicd.yml updated successfully"
300
+ }
293
301
  }
294
302
  },
295
303
  "packageJsonUpdates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisphere/nx",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",