@unisphere/nx 4.6.1 â 4.9.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.
- package/dist/generators/add-playground/add-playground.d.ts +5 -0
- package/dist/generators/add-playground/add-playground.d.ts.map +1 -0
- package/dist/generators/add-playground/add-playground.js +73 -0
- package/dist/generators/add-playground/schema.d.ts +5 -0
- package/dist/generators/add-playground/schema.json +29 -0
- package/dist/generators/add-playground/templates/react/playground.json.template +9 -0
- package/dist/generators/add-playground/templates/react/src/App.tsx.template +5 -0
- package/dist/generators/add-playground/templates/react/src/index.html.template +12 -0
- package/dist/generators/add-playground/templates/react/src/index.tsx.template +5 -0
- package/dist/generators/add-playground/templates/vanilla-js/playground.json.template +6 -0
- package/dist/generators/add-playground/templates/vanilla-js/src/index.html.template +12 -0
- package/dist/generators/add-playground/templates/vanilla-js/src/index.js.template +2 -0
- package/dist/generators/add-playground/templates/vanilla-ts/playground.json.template +6 -0
- package/dist/generators/add-playground/templates/vanilla-ts/src/index.html.template +12 -0
- package/dist/generators/add-playground/templates/vanilla-ts/src/index.ts.template +2 -0
- package/dist/migrations/4-8-0/restore-security-audit-step.d.ts +3 -0
- package/dist/migrations/4-8-0/restore-security-audit-step.d.ts.map +1 -0
- package/dist/migrations/4-8-0/restore-security-audit-step.js +45 -0
- package/generators.json +5 -0
- package/migrations.json +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { AddPlaygroundGeneratorSchema } from './schema';
|
|
3
|
+
export declare function addPlaygroundGenerator(tree: Tree, options: AddPlaygroundGeneratorSchema): Promise<() => void>;
|
|
4
|
+
export default addPlaygroundGenerator;
|
|
5
|
+
//# sourceMappingURL=add-playground.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-playground.d.ts","sourceRoot":"","sources":["../../../src/generators/add-playground/add-playground.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAiB,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AA6CxD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,uBAmDtC;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addPlaygroundGenerator = addPlaygroundGenerator;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const path = tslib_1.__importStar(require("path"));
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const VALID_ENGINES = ['vanilla-ts', 'vanilla-js', 'react'];
|
|
9
|
+
function validateOptions(options) {
|
|
10
|
+
if (!options.name || options.name.trim() === '') {
|
|
11
|
+
throw new Error(`Missing required option: 'name'\n` +
|
|
12
|
+
` Description: The name of the playground to create\n` +
|
|
13
|
+
` Type: string\n` +
|
|
14
|
+
` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
|
|
15
|
+
` Example: nx g @unisphere/nx:add-playground --name=my-demo --engine=react`);
|
|
16
|
+
}
|
|
17
|
+
const namePattern = /^[a-zA-Z][a-zA-Z0-9\-\s]*$/;
|
|
18
|
+
if (!namePattern.test(options.name)) {
|
|
19
|
+
throw new Error(`Invalid value '${options.name}' for option 'name'\n` +
|
|
20
|
+
` Pattern: ^[a-zA-Z][a-zA-Z0-9\\-\\s]*$\n` +
|
|
21
|
+
` Received: ${options.name}`);
|
|
22
|
+
}
|
|
23
|
+
if (!options.engine || !VALID_ENGINES.includes(options.engine)) {
|
|
24
|
+
throw new Error(`Invalid value '${options.engine}' for option 'engine'\n` +
|
|
25
|
+
` Allowed values: ${VALID_ENGINES.join(', ')}\n` +
|
|
26
|
+
` Example: nx g @unisphere/nx:add-playground --name=demo --engine=react`);
|
|
27
|
+
}
|
|
28
|
+
if (options.group) {
|
|
29
|
+
const groupPattern = /^[a-zA-Z0-9][a-zA-Z0-9\-_/]*$/;
|
|
30
|
+
if (!groupPattern.test(options.group)) {
|
|
31
|
+
throw new Error(`Invalid value '${options.group}' for option 'group'\n` +
|
|
32
|
+
` Group path must contain only letters, numbers, hyphens, underscores, and forward slashes\n` +
|
|
33
|
+
` Example: --group=getting-started or --group=advanced/hooks`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function addPlaygroundGenerator(tree, options) {
|
|
38
|
+
validateOptions(options);
|
|
39
|
+
// Ensure we're in a valid Unisphere workspace
|
|
40
|
+
(0, utils_1.validateUnisphereConfig)(tree);
|
|
41
|
+
const playgroundName = (0, devkit_1.names)(options.name).fileName;
|
|
42
|
+
const engine = options.engine;
|
|
43
|
+
// Build target path
|
|
44
|
+
const groupPath = options.group ? options.group.replace(/^\/|\/$/g, '') : '';
|
|
45
|
+
const targetDir = groupPath
|
|
46
|
+
? `unisphere/playgrounds/${groupPath}/${playgroundName}`
|
|
47
|
+
: `unisphere/playgrounds/${playgroundName}`;
|
|
48
|
+
// Check if already exists
|
|
49
|
+
if (tree.exists(`${targetDir}/playground.json`)) {
|
|
50
|
+
throw new Error(`Playground already exists at "${targetDir}".\n` +
|
|
51
|
+
'Please choose a different name or remove the existing playground first.');
|
|
52
|
+
}
|
|
53
|
+
// Template variables
|
|
54
|
+
const templateVars = {
|
|
55
|
+
...(0, utils_1.createNameTransforms)(playgroundName, 'playgroundName'),
|
|
56
|
+
tmpl: '',
|
|
57
|
+
};
|
|
58
|
+
// Generate files from engine-specific templates
|
|
59
|
+
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'templates', engine), targetDir, templateVars);
|
|
60
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
61
|
+
return () => {
|
|
62
|
+
devkit_1.logger.info('');
|
|
63
|
+
devkit_1.logger.info('â
Code playground created successfully!');
|
|
64
|
+
devkit_1.logger.info('');
|
|
65
|
+
devkit_1.logger.info(`đ Location: ${targetDir}`);
|
|
66
|
+
devkit_1.logger.info(`đ§ Engine: ${engine}`);
|
|
67
|
+
if (groupPath) {
|
|
68
|
+
devkit_1.logger.info(`đ Group: ${groupPath}`);
|
|
69
|
+
}
|
|
70
|
+
devkit_1.logger.info('');
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
exports.default = addPlaygroundGenerator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "AddPlayground",
|
|
4
|
+
"title": "Add a code playground",
|
|
5
|
+
"description": "Scaffold a new code playground example",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Playground name (letters, numbers, hyphens, spaces)",
|
|
11
|
+
"pattern": "^[a-zA-Z][a-zA-Z0-9\\-\\s]*$"
|
|
12
|
+
},
|
|
13
|
+
"group": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Optional group path (e.g., 'getting-started' or 'advanced/hooks')"
|
|
16
|
+
},
|
|
17
|
+
"engine": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "Template engine to use",
|
|
20
|
+
"oneOf": [
|
|
21
|
+
{ "const": "vanilla-ts", "title": "Vanilla TypeScript" },
|
|
22
|
+
{ "const": "vanilla-js", "title": "Vanilla JavaScript" },
|
|
23
|
+
{ "const": "react", "title": "React (TSX)" }
|
|
24
|
+
],
|
|
25
|
+
"default": "vanilla-ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"required": ["name", "engine"]
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title><%= playgroundName__humanReadable %></title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="./index.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title><%= playgroundName__humanReadable %></title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"></div>
|
|
10
|
+
<script type="module" src="./index.js"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title><%= playgroundName__humanReadable %></title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"></div>
|
|
10
|
+
<script type="module" src="./index.ts"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restore-security-audit-step.d.ts","sourceRoot":"","sources":["../../../src/migrations/4-8-0/restore-security-audit-step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,YAAY,CAAC;AAO1C,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAiD9D"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const AUDIT_STEP = ` - name: Security Audit
|
|
6
|
+
run: npx unisphere tools audit
|
|
7
|
+
env:
|
|
8
|
+
KALTURA_JFROG_TOKEN: \${{ steps.setup-jfrog.outputs.oidc-token }}`;
|
|
9
|
+
async function update(tree) {
|
|
10
|
+
const cicdPath = '.github/workflows/cicd.yml';
|
|
11
|
+
if (!tree.exists(cicdPath)) {
|
|
12
|
+
devkit_1.logger.warn('â ī¸ No cicd.yml found, skipping');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let content = tree.read(cicdPath, 'utf-8');
|
|
16
|
+
if (!content) {
|
|
17
|
+
devkit_1.logger.warn('â ī¸ Could not read cicd.yml, skipping');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const commentedPattern = /^[ \t]*#\s*- name: Security Audit\s*\n(?:[ \t]*#.*\n)*/m;
|
|
21
|
+
if (commentedPattern.test(content)) {
|
|
22
|
+
content = content.replace(commentedPattern, AUDIT_STEP + '\n');
|
|
23
|
+
tree.write(cicdPath, content);
|
|
24
|
+
devkit_1.logger.info('â
Uncommented Security Audit step in cicd.yml');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (content.includes('Security Audit')) {
|
|
28
|
+
devkit_1.logger.info('âšī¸ Security Audit step already exists in cicd.yml');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const installDepsMatch = content.match(/( *- name: Install Dependencies[ \t]*\n(?:.*\n)*?)([ \t]*- name: )/);
|
|
32
|
+
if (!installDepsMatch) {
|
|
33
|
+
devkit_1.logger.warn('â ī¸ Could not find Install Dependencies step in cicd.yml');
|
|
34
|
+
throw new Error('Could not find Install Dependencies step in cicd.yml');
|
|
35
|
+
}
|
|
36
|
+
const insertIndex = installDepsMatch.index + installDepsMatch[1].length;
|
|
37
|
+
content =
|
|
38
|
+
content.slice(0, insertIndex) +
|
|
39
|
+
'\n' +
|
|
40
|
+
AUDIT_STEP +
|
|
41
|
+
'\n\n' +
|
|
42
|
+
content.slice(insertIndex);
|
|
43
|
+
tree.write(cicdPath, content);
|
|
44
|
+
devkit_1.logger.info('â
Added Security Audit step to cicd.yml');
|
|
45
|
+
}
|
package/generators.json
CHANGED
|
@@ -55,6 +55,11 @@
|
|
|
55
55
|
"factory": "./dist/generators/internal-dev-runner/generator",
|
|
56
56
|
"schema": "./dist/generators/internal-dev-runner/schema.json",
|
|
57
57
|
"description": "Internal-dev-runner - Run a migration for testing purposes (dev only)"
|
|
58
|
+
},
|
|
59
|
+
"add-playground": {
|
|
60
|
+
"factory": "./dist/generators/add-playground/add-playground",
|
|
61
|
+
"schema": "./dist/generators/add-playground/schema.json",
|
|
62
|
+
"description": "Add a code playground example"
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
}
|
package/migrations.json
CHANGED
|
@@ -450,6 +450,14 @@
|
|
|
450
450
|
"cli": {
|
|
451
451
|
"postUpdateMessage": "â
GitHub documentation workflow added"
|
|
452
452
|
}
|
|
453
|
+
},
|
|
454
|
+
"4-8-0-restore-security-audit-step": {
|
|
455
|
+
"version": "4.8.0",
|
|
456
|
+
"description": "Restores Security Audit step in cicd.yml if commented out or missing",
|
|
457
|
+
"factory": "./dist/migrations/4-8-0/restore-security-audit-step.js",
|
|
458
|
+
"cli": {
|
|
459
|
+
"postUpdateMessage": "â
Security Audit step restored in cicd.yml"
|
|
460
|
+
}
|
|
453
461
|
}
|
|
454
462
|
},
|
|
455
463
|
"packageJsonUpdates": {
|
|
@@ -761,6 +769,28 @@
|
|
|
761
769
|
"alwaysAddToPackageJson": false
|
|
762
770
|
}
|
|
763
771
|
}
|
|
772
|
+
},
|
|
773
|
+
"4.7.0": {
|
|
774
|
+
"version": "4.7.0",
|
|
775
|
+
"cli": "nx",
|
|
776
|
+
"postUpdateMessage": "đ Migration to @unisphere/nx 4.7.0 completed successfully!",
|
|
777
|
+
"packages": {
|
|
778
|
+
"@unisphere/cli": {
|
|
779
|
+
"version": "5.1.0",
|
|
780
|
+
"alwaysAddToPackageJson": false
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
"4.8.0": {
|
|
785
|
+
"version": "4.8.0",
|
|
786
|
+
"cli": "nx",
|
|
787
|
+
"postUpdateMessage": "đ Migration to @unisphere/nx 4.8.0 completed successfully!",
|
|
788
|
+
"packages": {
|
|
789
|
+
"@unisphere/cli": {
|
|
790
|
+
"version": "5.2.0",
|
|
791
|
+
"alwaysAddToPackageJson": false
|
|
792
|
+
}
|
|
793
|
+
}
|
|
764
794
|
}
|
|
765
795
|
}
|
|
766
796
|
}
|