create-unisphere-project 1.0.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.
Files changed (38) hide show
  1. package/README.md +56 -0
  2. package/_templates/unisphere-project/.changeset/README.md +8 -0
  3. package/_templates/unisphere-project/.changeset/config.json +12 -0
  4. package/_templates/unisphere-project/.editorconfig +13 -0
  5. package/_templates/unisphere-project/.eslintignore +1 -0
  6. package/_templates/unisphere-project/.eslintrc.json +46 -0
  7. package/_templates/unisphere-project/.github/workflows/_publish-artifacts.yml +195 -0
  8. package/_templates/unisphere-project/.github/workflows/cicd.yml +55 -0
  9. package/_templates/unisphere-project/.nvmrc +1 -0
  10. package/_templates/unisphere-project/.prettierignore +5 -0
  11. package/_templates/unisphere-project/.prettierrc +3 -0
  12. package/_templates/unisphere-project/.unisphere +11 -0
  13. package/_templates/unisphere-project/README.md +1 -0
  14. package/_templates/unisphere-project/jest.config.ts +5 -0
  15. package/_templates/unisphere-project/jest.preset.js +3 -0
  16. package/_templates/unisphere-project/nx.json +76 -0
  17. package/_templates/unisphere-project/package-lock.json +26338 -0
  18. package/_templates/unisphere-project/package.json +107 -0
  19. package/_templates/unisphere-project/patches/@changesets+cli+2.27.11.patch +58 -0
  20. package/_templates/unisphere-project/patches/@nx+rollup+19.2.2.patch +29 -0
  21. package/_templates/unisphere-project/tsconfig.base.json +22 -0
  22. package/_templates/unisphere-project/unisphere/applications/.gitkeep +0 -0
  23. package/_templates/unisphere-project/unisphere/packages/.gitkeep +0 -0
  24. package/_templates/unisphere-project/unisphere/runtimes/.gitkeep +0 -0
  25. package/_templates/unisphere-project/vitest.workspace.ts +1 -0
  26. package/package.json +44 -0
  27. package/src/index.d.ts +1 -0
  28. package/src/index.js +8 -0
  29. package/src/index.js.map +1 -0
  30. package/src/lib/create-unisphere-repo-command.d.ts +2 -0
  31. package/src/lib/create-unisphere-repo-command.js +242 -0
  32. package/src/lib/create-unisphere-repo-command.js.map +1 -0
  33. package/src/lib/overwrite-placeholders.d.ts +4 -0
  34. package/src/lib/overwrite-placeholders.js +119 -0
  35. package/src/lib/overwrite-placeholders.js.map +1 -0
  36. package/src/lib/utils.d.ts +6 -0
  37. package/src/lib/utils.js +31 -0
  38. package/src/lib/utils.js.map +1 -0
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # 🪐 create-unisphere-project
2
+
3
+ Scaffold a new Unisphere-powered project in seconds.
4
+
5
+ This CLI helps you quickly set up a Unisphere project with a working structure, preconfigured settings, and best practices built-in.
6
+
7
+ ## ✨ Features
8
+
9
+ - Initializes a new Unisphere-compatible project
10
+ - Supports different Unisphere element types (runtime, packages, applications)
11
+ - Built-in prompts for configuration
12
+
13
+ ## 🚀 Quick Start
14
+
15
+ Using **npm**:
16
+
17
+ ```bash
18
+ npm create unisphere-project@latest
19
+ ```
20
+
21
+ You’ll be guided through a series of prompts to configure your new project.
22
+
23
+
24
+
25
+ ## ✨ What is Unisphere?
26
+
27
+ **Unisphere** is a framework developed by [Kaltura](https://www.kaltura.com) for building dynamic, composable frontend experiences at scale.
28
+
29
+ Learn more: [Unisphere Documentation](https://unisphere.kaltura.com)
30
+
31
+
32
+
33
+ ## 🛠 Local Development (for maintainers)
34
+
35
+ To test this CLI locally:
36
+
37
+ Clone the repository:
38
+
39
+ ```bash
40
+ git clone https://github.com/kaltura/unisphere-cli.git
41
+ cd create-unisphere
42
+ ```
43
+
44
+ Then run in the root directory:
45
+
46
+ ```bash
47
+ npm run create-unisphere-project
48
+ ```
49
+
50
+
51
+
52
+ ### 📦 Publishing
53
+
54
+ After doing changes to the code, create a commit following the semantic versioning rules. And push it to the remote repository.
55
+
56
+ Note that the commit must contain changes under the folder `packages/create-unisphere-project` to signal the ci to publish the package to npm.
@@ -0,0 +1,8 @@
1
+ # Changesets
2
+
3
+ Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4
+ with multi-package repos, or single-package repos to help you version and publish your code. You can
5
+ find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6
+
7
+ We have a quick list of common questions to get you started engaging with this project in
8
+ [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
3
+ "changelog": "@changesets/cli/changelog",
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "restricted",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": [],
11
+ "privatePackages": { "version": false, "tag": false }
12
+ }
@@ -0,0 +1,13 @@
1
+ # Editor configuration, see http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.md]
12
+ max_line_length = off
13
+ trim_trailing_whitespace = false
@@ -0,0 +1 @@
1
+ node_modules
@@ -0,0 +1,46 @@
1
+ {
2
+ "root": true,
3
+ "ignorePatterns": ["**/*"],
4
+ "plugins": ["@nx"],
5
+ "overrides": [
6
+ {
7
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8
+ "rules": {
9
+ "@nx/enforce-module-boundaries": [
10
+ "error",
11
+ {
12
+ "enforceBuildableLibDependency": true,
13
+ "allow": [],
14
+ "depConstraints": [
15
+ {
16
+ "sourceTag": "*",
17
+ "onlyDependOnLibsWithTags": ["*"]
18
+ }
19
+ ]
20
+ }
21
+ ]
22
+ }
23
+ },
24
+ {
25
+ "files": ["*.ts", "*.tsx"],
26
+ "extends": ["plugin:@nx/typescript"],
27
+ "rules": {
28
+ "@typescript-eslint/no-empty-function": "off"
29
+ }
30
+ },
31
+ {
32
+ "files": ["*.js", "*.jsx"],
33
+ "extends": ["plugin:@nx/javascript"],
34
+ "rules": {}
35
+ },
36
+ {
37
+ "files": ["*.json"],
38
+ "parser": "jsonc-eslint-parser",
39
+ "rules": {
40
+ "@nx/dependency-checks": ["error", {
41
+ "ignoredFiles": ["**/vite.config.ts", "**/rollup.config.js"]
42
+ }]
43
+ }
44
+ }
45
+ ]
46
+ }
@@ -0,0 +1,195 @@
1
+ name: Shared Deployment Jobs
2
+
3
+ on:
4
+ workflow_call:
5
+
6
+ jobs:
7
+ prepare-runtimes:
8
+ runs-on: codebuild-ovp-unisphere-runner-${{ github.run_id }}-${{ github.attempt }}
9
+
10
+ outputs:
11
+ unisphereElementsArtifactsFolder: ${{ steps.prepare-runtimes.outputs.artifactsRootFolder }}
12
+ hasArtifacts: ${{ steps.prepare-runtimes.outputs.hasArtifacts }}
13
+ commit_sha: ${{ steps.capture_commit_sha.outputs.commit_sha }}
14
+ steps:
15
+ - name: Checkout Repo
16
+ uses: actions/checkout@v3
17
+ with:
18
+ ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
19
+ fetch-tags: true
20
+ - name: Setup Node.js
21
+ uses: actions/setup-node@v4
22
+ with:
23
+ node-version-file: '.nvmrc'
24
+ - name: Clean workspace
25
+ run: git reset --hard HEAD
26
+ - name: Clean npm cache
27
+ run: npm cache clean --force
28
+ - name: Install dependencies
29
+ run: npm ci --include=optional
30
+ env:
31
+ GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32
+ - name: Prepare Unisphere Elements
33
+ id: prepare-runtimes
34
+ run: npx unisphere runtime publish prepare --verbose
35
+ - name: Capture Commit SHA
36
+ id: capture_commit_sha
37
+ run: echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_ENV
38
+ - name: Set commit_sha as output
39
+ id: set_commit_sha
40
+ run: echo "commit_sha=${{ env.commit_sha }}" >> $GITHUB_OUTPUT
41
+ - uses: actions/upload-artifact@v4
42
+ id: upload-unisphere-elements-artifacts
43
+ with:
44
+ name: unisphere-elements
45
+ path: ${{ steps.prepare-runtimes.outputs.artifactsRootFolder }}
46
+ retention-days: 1
47
+
48
+ deploy-packages:
49
+ runs-on: codebuild-ovp-unisphere-runner-${{ github.run_id }}-${{ github.attempt }}
50
+ steps:
51
+ - name: Checkout Repo
52
+ uses: actions/checkout@v3
53
+ with:
54
+ ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
55
+ fetch-tags: true
56
+ - name: Setup Node.js
57
+ uses: actions/setup-node@v4
58
+ with:
59
+ node-version: 20
60
+ - name: Install dependencies
61
+ run: npm ci --include=optional
62
+ env:
63
+ GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64
+ - name: Get NPM Token from AWS Secrets Manager
65
+ id: get-npm-token
66
+ run: |
67
+ NPM_TOKEN=$(aws secretsmanager get-secret-value --secret-id arn:aws:secretsmanager:eu-central-1:785328604905:secret:unisphere-secrets-um86Cs --query SecretString --output text | jq -r '."NPM_UNISPHERE_TOKEN"')
68
+ echo "NPM_TOKEN=$NPM_TOKEN" >> $GITHUB_ENV
69
+ # Debug token existence (safely)
70
+ echo "::debug::Token exists: $([ ! -z "$NPM_TOKEN" ] && echo 'true' || echo 'false')"
71
+ - name: Deploy to registry
72
+ run: npx unisphere package publish --verbose --githubToken ${{ secrets.GITHUB_TOKEN }} --npmToken ${{ env.NPM_TOKEN }} --branch "${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}"
73
+
74
+ deploy-runtimes:
75
+ if: needs.prepare-runtimes.outputs.hasArtifacts == 'true'
76
+ needs: prepare-runtimes
77
+ runs-on: codebuild-ovp-unisphere-runner-${{ github.run_id }}-${{ github.attempt }}
78
+ strategy:
79
+ matrix:
80
+ envs_regions:
81
+ - { env: 'nvp1', region: 'us-east-1', accountid: '583352821080' }
82
+ - { env: 'frp2', region: 'eu-central-1', accountid: '082111255551' }
83
+ - { env: 'irp2', region: 'eu-west-1', accountid: '137576761235' }
84
+ - { env: 'nvq2', region: 'us-east-1', accountid: '383697330906' }
85
+ fail-fast: false
86
+
87
+ steps:
88
+ - name: Checkout Repo at specific commit
89
+ uses: actions/checkout@v3
90
+ with:
91
+ ref: ${{ needs.prepare-runtimes.outputs.commit_sha }}
92
+ fetch-tags: true
93
+ - name: Setup Node.js
94
+ uses: actions/setup-node@v4
95
+ with:
96
+ node-version: 20
97
+ - name: Install dependencies
98
+ run: npm ci --include=optional
99
+ env:
100
+ GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101
+ - name: Download artifacts folder
102
+ uses: actions/download-artifact@v4
103
+ with:
104
+ name: unisphere-elements
105
+ path: ${{ needs.prepare-runtimes.outputs.unisphereElementsArtifactsFolder }}
106
+ - name: Sync S3 bucket
107
+ run: |
108
+ npx unisphere runtime publish execute \
109
+ --env ${{ matrix.envs_regions.env }} \
110
+ --aws-region '${{ matrix.envs_regions.region }}' \
111
+ --aws-arn 'arn:aws:iam::${{matrix.envs_regions.accountid }}:role/${{ matrix.envs_regions.env }}-unisphere-content-role' \
112
+ --artifacts-folder '${{ needs.prepare-runtimes.outputs.unisphereElementsArtifactsFolder }}' \
113
+ --verbose
114
+
115
+ prepare-applications:
116
+ runs-on: codebuild-ovp-unisphere-runner-${{ github.run_id }}-${{ github.attempt }}
117
+
118
+ outputs:
119
+ unisphereApplicationsArtifactsFolder: ${{ steps.prepare-applications.outputs.artifactsRootFolder }}
120
+ hasArtifacts: ${{ steps.prepare-applications.outputs.hasArtifacts }}
121
+ commit_sha: ${{ steps.capture_commit_sha.outputs.commit_sha }}
122
+ steps:
123
+ - name: Checkout Repo
124
+ uses: actions/checkout@v3
125
+ with:
126
+ ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
127
+ fetch-tags: true
128
+ - name: Setup Node.js
129
+ uses: actions/setup-node@v4
130
+ with:
131
+ node-version-file: '.nvmrc'
132
+ - name: Clean workspace
133
+ run: git reset --hard HEAD
134
+ - name: Clean npm cache
135
+ run: npm cache clean --force
136
+ - name: Install dependencies
137
+ run: npm ci --include=optional
138
+ env:
139
+ GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140
+ - name: Prepare Unisphere Applications
141
+ id: prepare-applications
142
+ run: npx unisphere application publish prepare --verbose
143
+ - name: Capture Commit SHA
144
+ id: capture_commit_sha
145
+ run: echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_ENV
146
+ - name: Set commit_sha as output
147
+ id: set_commit_sha
148
+ run: echo "commit_sha=${{ env.commit_sha }}" >> $GITHUB_OUTPUT
149
+ - uses: actions/upload-artifact@v4
150
+ id: upload-unisphere-applications-artifacts
151
+ with:
152
+ name: unisphere-applications
153
+ path: ${{ steps.prepare-applications.outputs.artifactsRootFolder }}
154
+ retention-days: 1
155
+
156
+ deploy-applications:
157
+ if: needs.prepare-applications.outputs.hasArtifacts == 'true'
158
+ needs: prepare-applications
159
+ runs-on: codebuild-ovp-unisphere-runner-${{ github.run_id }}-${{ github.attempt }}
160
+ strategy:
161
+ matrix:
162
+ envs_regions:
163
+ - { env: 'nvp1', region: 'us-east-1', accountid: '583352821080' }
164
+ - { env: 'frp2', region: 'eu-central-1', accountid: '082111255551' }
165
+ - { env: 'irp2', region: 'eu-west-1', accountid: '137576761235' }
166
+ - { env: 'nvq2', region: 'us-east-1', accountid: '383697330906' }
167
+ fail-fast: false
168
+
169
+ steps:
170
+ - name: Checkout Repo at specific commit
171
+ uses: actions/checkout@v3
172
+ with:
173
+ ref: ${{ needs.prepare-applications.outputs.commit_sha }}
174
+ fetch-tags: true
175
+ - name: Setup Node.js
176
+ uses: actions/setup-node@v4
177
+ with:
178
+ node-version: 20
179
+ - name: Install dependencies
180
+ run: npm ci --include=optional
181
+ env:
182
+ GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
183
+ - name: Download artifacts folder
184
+ uses: actions/download-artifact@v4
185
+ with:
186
+ name: unisphere-applications
187
+ path: ${{ needs.prepare-applications.outputs.unisphereApplicationsArtifactsFolder }}
188
+ - name: Sync S3 bucket
189
+ run: |
190
+ npx unisphere application publish execute \
191
+ --env ${{ matrix.envs_regions.env }} \
192
+ --aws-region '${{ matrix.envs_regions.region }}' \
193
+ --aws-arn 'arn:aws:iam::${{matrix.envs_regions.accountid }}:role/${{ matrix.envs_regions.env }}-unisphere-content-role' \
194
+ --artifacts-folder '${{ needs.prepare-applications.outputs.unisphereApplicationsArtifactsFolder }}' \
195
+ --verbose
@@ -0,0 +1,55 @@
1
+ name: CI/CD
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - 'prerelease/**'
8
+
9
+ jobs:
10
+ release:
11
+ name: Release
12
+ runs-on:
13
+ - codebuild-ovp-unisphere-runner-${{ github.run_id }}-${{ github.attempt }}
14
+ - instance-size:medium
15
+ outputs:
16
+ hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
17
+ steps:
18
+ - name: Check if part of prerelease or official release
19
+ id: check
20
+ run: |
21
+ if [ ! -f ".changeset/pre.json" ] && [ "${{ github.ref }}" != "refs/heads/main" ]; then
22
+ echo "not part of prerelease or official release, skipping job"
23
+ echo "::stop-commands::`date +%s`"
24
+ exit 0
25
+ fi
26
+
27
+ - name: Checkout Repo
28
+ uses: actions/checkout@v3
29
+
30
+ - name: Setup Node.js
31
+ uses: actions/setup-node@v4
32
+ with:
33
+ node-version-file: '.nvmrc'
34
+
35
+ - name: Install Dependencies
36
+ run: npm ci --include=optional
37
+ env:
38
+ GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39
+
40
+ - name: Create Release Pull Request or Publish to npm
41
+ id: changesets
42
+ uses: changesets/action@v1
43
+ env:
44
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45
+
46
+ - name: Create release tags
47
+ if: steps.changesets.outputs.hasChangesets == 'false'
48
+ run: |
49
+ npx changeset tag
50
+ git push --follow-tags
51
+
52
+ publish-artifacts:
53
+ needs: release
54
+ if: needs.release.outputs.hasChangesets == 'false'
55
+ uses: ./.github/workflows/_publish-artifacts.yml
@@ -0,0 +1 @@
1
+ 24
@@ -0,0 +1,5 @@
1
+ # Add files here to ignore them from prettier formatting
2
+ /dist
3
+ /coverage
4
+ /.nx/cache
5
+ /.nx/workspace-data
@@ -0,0 +1,3 @@
1
+ {
2
+ "singleQuote": true
3
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "company": "{{company-name|lower-dash-case}}",
3
+ "type": "widget",
4
+ "name": "{{project-name|lower-dash-case}}",
5
+ "schemaVersion": "1.0.0",
6
+ "elements": {
7
+ "applications": {},
8
+ "runtimes": {},
9
+ "packages": {}
10
+ }
11
+ }
@@ -0,0 +1 @@
1
+ # Unisphere {{company-name|human-readable}} {{project-name|human-readable}}
@@ -0,0 +1,5 @@
1
+ import { getJestProjectsAsync } from '@nx/jest';
2
+
3
+ export default async () => ({
4
+ projects: await getJestProjectsAsync(),
5
+ });
@@ -0,0 +1,3 @@
1
+ const nxPreset = require('@nx/jest/preset').default;
2
+
3
+ module.exports = { ...nxPreset };
@@ -0,0 +1,76 @@
1
+ {
2
+ "$schema": "./node_modules/nx/schemas/nx-schema.json",
3
+ "namedInputs": {
4
+ "default": ["{projectRoot}/**/*", "sharedGlobals"],
5
+ "production": [
6
+ "default",
7
+ "!{projectRoot}/.eslintrc.json",
8
+ "!{projectRoot}/eslint.config.js",
9
+ "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
10
+ "!{projectRoot}/tsconfig.spec.json",
11
+ "!{projectRoot}/jest.config.[jt]s",
12
+ "!{projectRoot}/src/test-setup.[jt]s",
13
+ "!{projectRoot}/test-setup.[jt]s",
14
+ "!{projectRoot}/**/*.stories.@(js|jsx|ts|tsx|mdx)",
15
+ "!{projectRoot}/.storybook/**/*",
16
+ "!{projectRoot}/tsconfig.storybook.json"
17
+ ],
18
+ "sharedGlobals": []
19
+ },
20
+ "plugins": [
21
+ {
22
+ "plugin": "@nx/eslint/plugin",
23
+ "options": {
24
+ "targetName": "lint"
25
+ }
26
+ },
27
+ {
28
+ "plugin": "@nx/rollup/plugin",
29
+ "options": {
30
+ "buildTargetName": "build"
31
+ }
32
+ },
33
+ {
34
+ "plugin": "@nx/vite/plugin",
35
+ "options": {
36
+ "buildTargetName": "build",
37
+ "testTargetName": "test",
38
+ "serveTargetName": "serve",
39
+ "previewTargetName": "preview",
40
+ "serveStaticTargetName": "serve-static"
41
+ }
42
+ },
43
+ {
44
+ "plugin": "@nx/webpack/plugin",
45
+ "options": {
46
+ "buildTargetName": "build",
47
+ "serveTargetName": "serve",
48
+ "previewTargetName": "preview"
49
+ }
50
+ },
51
+ {
52
+ "plugin": "@nx/jest/plugin",
53
+ "options": {
54
+ "targetName": "test"
55
+ }
56
+ }
57
+ ],
58
+ "generators": {
59
+ "@nx/react": {
60
+ "library": {
61
+ "style": "css",
62
+ "linter": "eslint",
63
+ "unitTestRunner": "vitest"
64
+ },
65
+ "application": {
66
+ "babel": true,
67
+ "style": "css",
68
+ "linter": "eslint",
69
+ "bundler": "webpack"
70
+ },
71
+ "component": {
72
+ "style": "css"
73
+ }
74
+ }
75
+ }
76
+ }