@knapsack/renderer-react 4.71.16--canary.5224.facfa79.0 → 4.71.16--canary.5239.d839174.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +29 -0
- package/ava.config.cjs +1 -7
- package/dist/client/init.d.mts +2 -2
- package/dist/client/init.d.ts +2 -0
- package/dist/client/init.js +5 -0
- package/dist/client/init.js.map +1 -0
- package/dist/client/init.mjs +3 -39
- package/dist/client/init.mjs.map +1 -1
- package/dist/demo-wrapper.d.mts +7 -0
- package/dist/demo-wrapper.d.ts +7 -0
- package/dist/demo-wrapper.js +2 -0
- package/dist/demo-wrapper.js.map +1 -0
- package/dist/demo-wrapper.mjs +2 -0
- package/dist/demo-wrapper.mjs.map +1 -0
- package/dist/error-catcher.d.mts +20 -0
- package/dist/error-catcher.d.ts +20 -0
- package/dist/error-catcher.js +2 -0
- package/dist/error-catcher.js.map +1 -0
- package/dist/error-catcher.mjs +2 -0
- package/dist/error-catcher.mjs.map +1 -0
- package/dist/{renderer-react.d.ts → index.d.mts} +5 -2
- package/dist/index.d.ts +45 -3
- package/dist/index.js +31 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -0
- package/dist/index.mjs.map +1 -0
- package/dist/prototype-template.d.mts +7 -0
- package/dist/prototype-template.d.ts +7 -0
- package/dist/prototype-template.js +2 -0
- package/dist/prototype-template.js.map +1 -0
- package/dist/prototype-template.mjs +2 -0
- package/dist/prototype-template.mjs.map +1 -0
- package/dist/types-CivTHEEo.d.mts +10 -0
- package/dist/types-CivTHEEo.d.ts +10 -0
- package/package.json +27 -23
- package/tsconfig.json +2 -2
- package/tsup.config.cjs +5 -0
- package/dist/analyze/infer-spec.test.d.ts +0 -2
- package/dist/analyze/infer-spec.test.d.ts.map +0 -1
- package/dist/analyze/infer-spec.test.js +0 -112
- package/dist/analyze/infer-spec.test.js.map +0 -1
- package/dist/analyze/mui.test.d.ts +0 -2
- package/dist/analyze/mui.test.d.ts.map +0 -1
- package/dist/analyze/mui.test.js +0 -60
- package/dist/analyze/mui.test.js.map +0 -1
- package/dist/analyze/pkg-basic.test.d.ts +0 -2
- package/dist/analyze/pkg-basic.test.d.ts.map +0 -1
- package/dist/analyze/pkg-basic.test.js +0 -33
- package/dist/analyze/pkg-basic.test.js.map +0 -1
- package/dist/analyze/pkg-diff-types.test.d.ts +0 -2
- package/dist/analyze/pkg-diff-types.test.d.ts.map +0 -1
- package/dist/analyze/pkg-diff-types.test.js +0 -43
- package/dist/analyze/pkg-diff-types.test.js.map +0 -1
- package/dist/client/init.d.mts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/react-creators.d.ts +0 -20
- package/dist/react-creators.d.ts.map +0 -1
- package/dist/react-creators.js +0 -170
- package/dist/react-creators.js.map +0 -1
- package/dist/renderer-react.d.ts.map +0 -1
- package/dist/renderer-react.js +0 -569
- package/dist/renderer-react.js.map +0 -1
- package/dist/types.d.ts +0 -19
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -28
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -500
- package/dist/utils.js.map +0 -1
- package/dist/utils.test.d.ts +0 -2
- package/dist/utils.test.d.ts.map +0 -1
- package/dist/utils.test.js +0 -59
- package/dist/utils.test.js.map +0 -1
- package/prototype-template.d.mts +0 -3
- package/prototype-template.mjs +0 -3
- package/test-fixtures/pkg-diff-types/button.js +0 -10
- package/test-fixtures/pkg-diff-types/package.json +0 -4
- package/test-fixtures/pkg-diff-types/readme.md +0 -1
- package/test-fixtures/pkg-diff-types/types/button.d.ts +0 -5
package/package.json
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@knapsack/renderer-react",
|
3
3
|
"description": "Render React",
|
4
|
-
"version": "4.71.16--canary.
|
4
|
+
"version": "4.71.16--canary.5239.d839174.0",
|
5
5
|
"type": "commonjs",
|
6
|
+
"main": "dist/index.js",
|
7
|
+
"types": "dist/index.d.ts",
|
6
8
|
"exports": {
|
7
9
|
".": {
|
8
10
|
"types": "./dist/index.d.ts",
|
@@ -15,30 +17,31 @@
|
|
15
17
|
"./package": "./package.json",
|
16
18
|
"./package.json": "./package.json",
|
17
19
|
"./prototype-template": {
|
18
|
-
"types": "./prototype-template.d.
|
19
|
-
"
|
20
|
+
"types": "./dist/prototype-template.d.ts",
|
21
|
+
"import": "./dist/prototype-template.mjs",
|
22
|
+
"require": "./dist/prototype-template.js",
|
23
|
+
"default": "./dist/prototype-template.mjs"
|
20
24
|
}
|
21
25
|
},
|
22
|
-
"sideEffects":
|
23
|
-
"./dist/client/init.mjs"
|
24
|
-
],
|
26
|
+
"sideEffects": false,
|
25
27
|
"scripts": {
|
26
|
-
"build": "
|
28
|
+
"build": "tsup src/index.ts src/error-catcher.tsx src/demo-wrapper.tsx src/prototype-template.tsx src/client/init.tsx",
|
27
29
|
"clean": "rm -rf dist",
|
28
|
-
"lint": "eslint ./src --quiet",
|
29
|
-
"test": "
|
30
|
+
"lint": "eslint ./src ./tests --quiet",
|
31
|
+
"test": "npm run test:types && npm run test:unit",
|
32
|
+
"test:types": "tsc",
|
33
|
+
"test:unit": "ava"
|
30
34
|
},
|
31
35
|
"author": "Knapsack",
|
32
36
|
"dependencies": {
|
33
37
|
"@babel/preset-react": "^7.25.9",
|
34
|
-
"@knapsack/app": "4.71.16--canary.
|
35
|
-
"@knapsack/creator-utils": "4.71.16--canary.
|
36
|
-
"@knapsack/file-utils": "4.71.16--canary.
|
37
|
-
"@knapsack/ks-file-utils": "4.71.16--canary.
|
38
|
-
"@knapsack/renderer-
|
39
|
-
"@knapsack/
|
40
|
-
"@knapsack/
|
41
|
-
"@knapsack/utils": "4.71.16--canary.5224.facfa79.0",
|
38
|
+
"@knapsack/app": "4.71.16--canary.5239.d839174.0",
|
39
|
+
"@knapsack/creator-utils": "4.71.16--canary.5239.d839174.0",
|
40
|
+
"@knapsack/file-utils": "4.71.16--canary.5239.d839174.0",
|
41
|
+
"@knapsack/ks-file-utils": "4.71.16--canary.5239.d839174.0",
|
42
|
+
"@knapsack/renderer-webpack-base": "4.71.16--canary.5239.d839174.0",
|
43
|
+
"@knapsack/types": "4.71.16--canary.5239.d839174.0",
|
44
|
+
"@knapsack/utils": "4.71.16--canary.5239.d839174.0",
|
42
45
|
"react": "^18.3.1",
|
43
46
|
"react-docgen": "^6.0.4",
|
44
47
|
"react-docgen-typescript": "^2.2.2",
|
@@ -47,10 +50,10 @@
|
|
47
50
|
"typescript": "^5.6.3"
|
48
51
|
},
|
49
52
|
"devDependencies": {
|
50
|
-
"@knapsack/eslint-config-starter": "4.71.16--canary.
|
51
|
-
"@knapsack/sandbox-components": "4.71.16--canary.
|
52
|
-
"@knapsack/test-ava": "4.71.16--canary.
|
53
|
-
"@knapsack/typescript-config-starter": "4.71.16--canary.
|
53
|
+
"@knapsack/eslint-config-starter": "4.71.16--canary.5239.d839174.0",
|
54
|
+
"@knapsack/sandbox-components": "4.71.16--canary.5239.d839174.0",
|
55
|
+
"@knapsack/test-ava": "4.71.16--canary.5239.d839174.0",
|
56
|
+
"@knapsack/typescript-config-starter": "4.71.16--canary.5239.d839174.0",
|
54
57
|
"@mui/material": "^5.16.7",
|
55
58
|
"@mui/x-data-grid": "^6.20.4",
|
56
59
|
"@types/node": "^20.17.8",
|
@@ -58,7 +61,8 @@
|
|
58
61
|
"@types/react-dom": "^18.3.1",
|
59
62
|
"ava": "^6.2.0",
|
60
63
|
"eslint": "^8.57.0",
|
61
|
-
"prop-types": "^15.8.1"
|
64
|
+
"prop-types": "^15.8.1",
|
65
|
+
"tsup": "^8.3.5"
|
62
66
|
},
|
63
67
|
"publishConfig": {
|
64
68
|
"access": "public"
|
@@ -68,5 +72,5 @@
|
|
68
72
|
"directory": "apps/client/renderers/renderer-react",
|
69
73
|
"type": "git"
|
70
74
|
},
|
71
|
-
"gitHead": "
|
75
|
+
"gitHead": "d839174feb8a20eccecdb49293d10ca269a417de"
|
72
76
|
}
|
package/tsconfig.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
|
-
"extends": "@knapsack/typescript-config-starter/tsconfig.
|
3
|
-
"include": ["src/**/*"],
|
2
|
+
"extends": "@knapsack/typescript-config-starter/tsconfig.test-only.json",
|
3
|
+
"include": ["src/**/*", "*.*", "tests/**/*"],
|
4
4
|
"exclude": ["**/dist"],
|
5
5
|
"compilerOptions": {
|
6
6
|
"strictNullChecks": false,
|
package/tsup.config.cjs
ADDED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"infer-spec.test.d.ts","sourceRoot":"","sources":["../../src/analyze/infer-spec.test.ts"],"names":[],"mappings":""}
|
@@ -1,112 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const ava_1 = __importDefault(require("ava"));
|
7
|
-
const types_1 = require("@knapsack/types");
|
8
|
-
const renderers_1 = require("@knapsack/app/renderers");
|
9
|
-
const utils_1 = require("../utils");
|
10
|
-
(0, ava_1.default)('infer types in packages with different files name for types', async (t) => {
|
11
|
-
const spec = await (0, utils_1.getReactDocs)({
|
12
|
-
src: '@knapsack/sandbox-components/react',
|
13
|
-
exportName: 'Button',
|
14
|
-
resolveFromDir: __dirname,
|
15
|
-
});
|
16
|
-
if (spec === false) {
|
17
|
-
t.fail(`Spec could not be inferred`);
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
t.truthy(spec);
|
21
|
-
t.deepEqual(Object.keys(spec.props.properties).sort(), ['label', 'mode', 'size', 'type'].sort());
|
22
|
-
if ((0, types_1.isOptionsProp)(spec.props.properties.size)) {
|
23
|
-
t.deepEqual(spec.props.properties.size.enum, ['small', 'medium', 'large']);
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
t.log(spec.props.properties.size);
|
27
|
-
t.fail(`size prop should be an options prop`);
|
28
|
-
}
|
29
|
-
if ((0, types_1.isOptionsProp)(spec.props.properties.type)) {
|
30
|
-
t.deepEqual(spec.props.properties.type.enum, ['filled', 'outlined']);
|
31
|
-
}
|
32
|
-
else {
|
33
|
-
t.log(spec.props.properties.type);
|
34
|
-
t.fail(`type prop should be an options prop`);
|
35
|
-
}
|
36
|
-
if ((0, types_1.isOptionsProp)(spec.props.properties.mode)) {
|
37
|
-
t.deepEqual(spec.props.properties.mode.enum, [
|
38
|
-
'default',
|
39
|
-
'success',
|
40
|
-
'error',
|
41
|
-
'warning',
|
42
|
-
]);
|
43
|
-
}
|
44
|
-
else {
|
45
|
-
t.log(spec.props.properties.mode);
|
46
|
-
t.fail(`mode prop should be an options prop`);
|
47
|
-
}
|
48
|
-
});
|
49
|
-
(0, ava_1.default)('inferDocs card.tsx with types', async (t) => {
|
50
|
-
const spec = await (0, utils_1.getReactDocs)({
|
51
|
-
src: '@knapsack/renderer-react-components/test-fixtures',
|
52
|
-
exportName: 'Card',
|
53
|
-
resolveFromDir: process.cwd(),
|
54
|
-
});
|
55
|
-
const expectedSpec = {
|
56
|
-
props: {
|
57
|
-
$schema: 'http://json-schema.org/draft-07/schema',
|
58
|
-
type: 'object',
|
59
|
-
required: ['cardBody', 'items'],
|
60
|
-
properties: {
|
61
|
-
textAlign: {
|
62
|
-
type: 'string',
|
63
|
-
enum: ['left', 'center', 'right'],
|
64
|
-
// @todo We lost proper default value when the source switched from `.tsx` to being from a package, which results in analyzing a `.d.ts` files... which doesn't have default values.
|
65
|
-
// default: 'left',
|
66
|
-
default: undefined,
|
67
|
-
},
|
68
|
-
imgSrc: {
|
69
|
-
type: 'string',
|
70
|
-
},
|
71
|
-
isDark: {
|
72
|
-
type: 'boolean',
|
73
|
-
// @todo We lost proper default value when the source switched from `.tsx` to being from a package, which results in analyzing a `.d.ts` files... which doesn't have default values.
|
74
|
-
// default: true,
|
75
|
-
},
|
76
|
-
cardTitle: {
|
77
|
-
type: 'string',
|
78
|
-
},
|
79
|
-
cardSubTitle: {
|
80
|
-
type: 'string',
|
81
|
-
},
|
82
|
-
cardBody: {
|
83
|
-
type: 'string',
|
84
|
-
},
|
85
|
-
handleIt: {
|
86
|
-
typeof: 'function',
|
87
|
-
tsType: '(x: string) => boolean',
|
88
|
-
},
|
89
|
-
items: {
|
90
|
-
tsType: '{ id: string; title: string; description?: string; }[]',
|
91
|
-
},
|
92
|
-
},
|
93
|
-
},
|
94
|
-
slots: {
|
95
|
-
children: {
|
96
|
-
description: 'Goes in footer',
|
97
|
-
title: 'children',
|
98
|
-
},
|
99
|
-
header: {
|
100
|
-
title: 'header',
|
101
|
-
},
|
102
|
-
},
|
103
|
-
};
|
104
|
-
if (spec === false) {
|
105
|
-
t.fail('Spec could not be inferred');
|
106
|
-
return;
|
107
|
-
}
|
108
|
-
const { ok, message } = (0, renderers_1.validateSpec)(spec);
|
109
|
-
t.is(ok, true, message);
|
110
|
-
t.deepEqual(spec, expectedSpec);
|
111
|
-
});
|
112
|
-
//# sourceMappingURL=infer-spec.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"infer-spec.test.js","sourceRoot":"","sources":["../../src/analyze/infer-spec.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AACvB,2CAAgE;AAChE,uDAAuD;AACvD,oCAAwC;AAExC,IAAA,aAAI,EAAC,6DAA6D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC9E,MAAM,IAAI,GAAG,MAAM,IAAA,oBAAY,EAAC;QAC9B,GAAG,EAAE,oCAAoC;QACzC,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,SAAS;KAC1B,CAAC,CAAC;IACH,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACf,CAAC,CAAC,SAAS,CACT,MAAM,CAAC,IAAI,CA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MAAM,EAAE;gBACN,KAAK,EAAE,QAAQ;aAChB;SACF;KACF,CAAC;IAEF,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IACD,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,IAAA,wBAAY,EAAC,IAAI,CAAC,CAAC;IAE3C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACxB,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mui.test.d.ts","sourceRoot":"","sources":["../../src/analyze/mui.test.ts"],"names":[],"mappings":""}
|
package/dist/analyze/mui.test.js
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const ava_1 = __importDefault(require("ava"));
|
7
|
-
const types_1 = require("@knapsack/types");
|
8
|
-
const utils_1 = require("../utils");
|
9
|
-
ava_1.default.serial('MUI strings with extra quotes', async (t) => {
|
10
|
-
const results = await (0, utils_1.getReactDocs)({
|
11
|
-
src: '@mui/x-data-grid',
|
12
|
-
exportName: 'DataGrid',
|
13
|
-
resolveFromDir: process.cwd(),
|
14
|
-
});
|
15
|
-
if (results === false) {
|
16
|
-
t.fail('Could not infer spec');
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
Object.entries(results.props.properties).forEach(([propName, prop]) => {
|
20
|
-
if ((0, types_1.isStringProp)(prop) || (0, types_1.isOptionsProp)(prop)) {
|
21
|
-
if (typeof prop.default === 'string') {
|
22
|
-
t.true(!prop.default.startsWith('"') && !prop.default.endsWith('"'), `prop "${propName}" has a default that should not be quoted: ${prop.default} - ${JSON.stringify(prop)}`);
|
23
|
-
}
|
24
|
-
}
|
25
|
-
if ((0, types_1.isOptionsProp)(prop)) {
|
26
|
-
if (prop.default) {
|
27
|
-
t.true(prop.enum.includes(prop.default), `For prop "${propName}", the default value "${prop.default}" is not in the enum: ${prop.enum}`);
|
28
|
-
}
|
29
|
-
prop.enum.forEach((option) => {
|
30
|
-
t.true(!option.startsWith('"') && !option.endsWith('"'), `option should not be quoted: ${prop.default}`);
|
31
|
-
});
|
32
|
-
}
|
33
|
-
if ((0, types_1.isNumberProp)(prop) && prop.default) {
|
34
|
-
const ok = t.is(typeof prop.default, 'number', `prop "${propName}" default should be a number: ${prop.default}`);
|
35
|
-
if (!ok) {
|
36
|
-
t.log(prop);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
if ((0, types_1.isBooleanProp)(prop) && prop.default) {
|
40
|
-
const ok = t.is(typeof prop.default, 'boolean', `prop "${propName}" should be a boolean: ${prop.default}`);
|
41
|
-
if (!ok) {
|
42
|
-
t.log(prop);
|
43
|
-
}
|
44
|
-
}
|
45
|
-
});
|
46
|
-
});
|
47
|
-
ava_1.default.failing('infer types for MUI Component', async (t) => {
|
48
|
-
const spec = await (0, utils_1.getReactDocs)({
|
49
|
-
src: '@mui/material',
|
50
|
-
exportName: 'Button',
|
51
|
-
resolveFromDir: process.cwd(),
|
52
|
-
});
|
53
|
-
if (spec === false) {
|
54
|
-
t.fail('Spec could not be inferred for MUI Component');
|
55
|
-
}
|
56
|
-
else {
|
57
|
-
t.pass('Spec was successfully inferred for MUI Component');
|
58
|
-
}
|
59
|
-
});
|
60
|
-
//# sourceMappingURL=mui.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mui.test.js","sourceRoot":"","sources":["../../src/analyze/mui.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AACvB,2CAKyB;AACzB,oCAAwC;AAExC,aAAI,CAAC,MAAM,C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AAC,8CAA8C,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACN,CAAC,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"pkg-basic.test.d.ts","sourceRoot":"","sources":["../../src/analyze/pkg-basic.test.ts"],"names":[],"mappings":""}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const ava_1 = __importDefault(require("ava"));
|
7
|
-
const types_1 = require("@knapsack/types");
|
8
|
-
const utils_1 = require("../utils");
|
9
|
-
(0, ava_1.default)('infer types in basic packages', async (t) => {
|
10
|
-
const spec = await (0, utils_1.getReactDocs)({
|
11
|
-
src: '@knapsack/renderer-react-components/test-fixtures',
|
12
|
-
exportName: 'Button',
|
13
|
-
resolveFromDir: __dirname,
|
14
|
-
});
|
15
|
-
if (spec === false) {
|
16
|
-
t.fail(`Spec could not be inferred`);
|
17
|
-
return;
|
18
|
-
}
|
19
|
-
t.deepEqual(Object.keys(spec.props.properties).sort(), ['size', 'text'].sort());
|
20
|
-
if (!(0, types_1.isStringProp)(spec.props.properties.text)) {
|
21
|
-
t.log(spec.props.properties.text);
|
22
|
-
t.fail(`text prop should be a string`);
|
23
|
-
return;
|
24
|
-
}
|
25
|
-
if (!(0, types_1.isOptionsProp)(spec.props.properties.size)) {
|
26
|
-
t.log(spec.props.properties.size);
|
27
|
-
t.fail(`size prop should be an options prop`);
|
28
|
-
return;
|
29
|
-
}
|
30
|
-
t.deepEqual(spec.props.properties.size.enum, ['small', 'medium', 'large']);
|
31
|
-
t.is(spec.slots.children.title, 'children', `Should detect "children" slot`);
|
32
|
-
});
|
33
|
-
//# sourceMappingURL=pkg-basic.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UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,+BAA+B,CAAC,CAAC;AAC/E,CAAC,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"pkg-diff-types.test.d.ts","sourceRoot":"","sources":["../../src/analyze/pkg-diff-types.test.ts"],"names":[],"mappings":""}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const ava_1 = __importDefault(require("ava"));
|
7
|
-
const path_1 = require("path");
|
8
|
-
const types_1 = require("@knapsack/types");
|
9
|
-
const utils_1 = require("../utils");
|
10
|
-
(0, ava_1.default)('infer types in packages with different files name for types', async (t) => {
|
11
|
-
const spec = await (0, utils_1.getReactDocs)({
|
12
|
-
src: (0, path_1.join)(__dirname, '../../test-fixtures/pkg-diff-types'),
|
13
|
-
exportName: 'Button',
|
14
|
-
resolveFromDir: __dirname,
|
15
|
-
});
|
16
|
-
if (spec === false) {
|
17
|
-
t.fail(`Spec could not be inferred`);
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
t.truthy(spec);
|
21
|
-
if (!spec.props) {
|
22
|
-
t.fail(`Spec should have props`);
|
23
|
-
return;
|
24
|
-
}
|
25
|
-
if (!spec.slots) {
|
26
|
-
t.fail(`Spec should have slots`);
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
t.deepEqual(Object.keys(spec.props.properties).sort(), ['size', 'text'].sort());
|
30
|
-
if (!(0, types_1.isStringProp)(spec.props.properties.text)) {
|
31
|
-
t.log(spec.props.properties.text);
|
32
|
-
t.fail(`text prop should be a string`);
|
33
|
-
return;
|
34
|
-
}
|
35
|
-
if (!(0, types_1.isOptionsProp)(spec.props.properties.size)) {
|
36
|
-
t.log(spec.props.properties.size);
|
37
|
-
t.fail(`size prop should be an options prop`);
|
38
|
-
return;
|
39
|
-
}
|
40
|
-
t.deepEqual(spec.props.properties.size.enum, ['small', 'medium', 'large']);
|
41
|
-
t.is(spec.slots.children.title, 'children', `Should detect "children" slot`);
|
42
|
-
});
|
43
|
-
//# sourceMappingURL=pkg-diff-types.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"pkg-diff-types.test.js","sourceRoot":"","sources":["../../src/analyze/pkg-diff-types.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AACvB,+BAA4B;AAC5B,2CAA8D;AAC9D,oCAAwC;AAExC,IAAA,aAAI,EAAC,6DAA6D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC9E,MAAM,IAAI,GAAG,MAAM,IAAA,oBAAY,EAAC;QAC9B,GAAG,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,oCAAoC,CAAC;QAC1D,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,SAAS;KAC1B,CAAC,CAAC;IACH,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IACD,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACf,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACjC,OAAO;IACT,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACjC,OAAO;IACT,CAAC;IACD,CAAC,CAAC,SAAS,CACT,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EACzC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CACxB,CAAC;IACF,IAAI,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QACvC,OAAO;IACT,CAAC;IACD,IAAI,CAAC,IAAA,qBAAa,EAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IACD,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,+BAA+B,CAAC,CAAC;AAC/E,CAAC,CAAC,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"init.d.mts","sourceRoot":"","sources":["../../src/client/init.mts"],"names":[],"mappings":""}
|
package/dist/index.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,YAAY,EACV,gBAAgB,GAEjB,MAAM,kDAAkD,CAAC"}
|
package/dist/react-creators.d.ts
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
export declare const createReactPattern: import("@knapsack/creator-utils").Creator<{
|
2
|
-
pkgPath: {
|
3
|
-
type: "text";
|
4
|
-
title: string;
|
5
|
-
};
|
6
|
-
importPrefix: {
|
7
|
-
type: "text";
|
8
|
-
title: string;
|
9
|
-
};
|
10
|
-
}, import("@knapsack/creator-utils").KsAnswers<{
|
11
|
-
pkgPath: {
|
12
|
-
type: "text";
|
13
|
-
title: string;
|
14
|
-
};
|
15
|
-
importPrefix: {
|
16
|
-
type: "text";
|
17
|
-
title: string;
|
18
|
-
};
|
19
|
-
}>>;
|
20
|
-
//# sourceMappingURL=react-creators.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"react-creators.d.ts","sourceRoot":"","sources":["../src/react-creators.ts"],"names":[],"mappings":"AAgEA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;GAsI7B,CAAC"}
|
package/dist/react-creators.js
DELETED
@@ -1,170 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createReactPattern = void 0;
|
4
|
-
const file_utils_1 = require("@knapsack/file-utils");
|
5
|
-
const creator_utils_1 = require("@knapsack/creator-utils");
|
6
|
-
const ks_file_utils_1 = require("@knapsack/ks-file-utils");
|
7
|
-
const utils_1 = require("@knapsack/utils");
|
8
|
-
function isCapitalLetter(char) {
|
9
|
-
return char.toUpperCase() === char;
|
10
|
-
}
|
11
|
-
function startsWithCapitalLetter(str) {
|
12
|
-
return isCapitalLetter(str[0]);
|
13
|
-
}
|
14
|
-
function createPatternData({ importName, id, title = importName, pkgPath, initialDemoId, }) {
|
15
|
-
return {
|
16
|
-
id,
|
17
|
-
title,
|
18
|
-
description: '',
|
19
|
-
statuses: {
|
20
|
-
main: 'ready',
|
21
|
-
},
|
22
|
-
templates: [
|
23
|
-
{
|
24
|
-
id: 'react',
|
25
|
-
title: 'react',
|
26
|
-
path: pkgPath,
|
27
|
-
alias: importName,
|
28
|
-
templateLanguageId: 'react',
|
29
|
-
spec: {
|
30
|
-
isInferred: true,
|
31
|
-
},
|
32
|
-
demoIds: [initialDemoId],
|
33
|
-
blockIds: [],
|
34
|
-
},
|
35
|
-
],
|
36
|
-
tabs: [
|
37
|
-
{
|
38
|
-
type: 'template',
|
39
|
-
id: 'react',
|
40
|
-
},
|
41
|
-
],
|
42
|
-
subPages: [],
|
43
|
-
};
|
44
|
-
}
|
45
|
-
exports.createReactPattern = (0, creator_utils_1.createCreator)({
|
46
|
-
id: 'react-patterns',
|
47
|
-
title: 'React Ks Patterns',
|
48
|
-
description: 'Adds React templates as Knapsack Patterns',
|
49
|
-
getQuestions: async () => ({
|
50
|
-
pkgPath: {
|
51
|
-
type: 'text',
|
52
|
-
title: 'Package path',
|
53
|
-
},
|
54
|
-
importPrefix: {
|
55
|
-
type: 'text',
|
56
|
-
title: 'Import Prefix to Remove',
|
57
|
-
},
|
58
|
-
}),
|
59
|
-
getTasks: async ({ answers: { pkgPath, importPrefix = '' }, config }) => {
|
60
|
-
const dataDir = config.dest;
|
61
|
-
const currentPatterns = await (0, ks_file_utils_1.readKsPatternConfigs)({
|
62
|
-
dataDir,
|
63
|
-
});
|
64
|
-
const currentReactPatternsImportNames = currentPatterns.reduce((cur, pattern) => {
|
65
|
-
var _a, _b;
|
66
|
-
const reactTemplates = (_b = (_a = pattern.templates) === null || _a === void 0 ? void 0 : _a.filter((t) => t.templateLanguageId === 'react')) !== null && _b !== void 0 ? _b : [];
|
67
|
-
cur.push(...reactTemplates.map((t) => t.alias));
|
68
|
-
return cur;
|
69
|
-
}, []);
|
70
|
-
const { exports: allImports } = await (0, file_utils_1.getJsExportNames)({
|
71
|
-
path: pkgPath,
|
72
|
-
});
|
73
|
-
return [
|
74
|
-
{
|
75
|
-
title: 'Pick Imports to add',
|
76
|
-
task: (_, task) => creator_utils_1.tasks.runSubCreator({
|
77
|
-
task,
|
78
|
-
config,
|
79
|
-
creator: (0, creator_utils_1.createCreator)({
|
80
|
-
id: 'react-pattern-import-names',
|
81
|
-
getQuestions: async () => ({
|
82
|
-
importNames: {
|
83
|
-
type: 'choices',
|
84
|
-
choices: allImports
|
85
|
-
.filter((importName) => startsWithCapitalLetter(importName) &&
|
86
|
-
!currentReactPatternsImportNames.includes(importName))
|
87
|
-
.map((importName) => ({
|
88
|
-
value: importName,
|
89
|
-
})),
|
90
|
-
},
|
91
|
-
}),
|
92
|
-
getTasks: async ({ answers }) => {
|
93
|
-
// not sure why TS failed to infer this. happened during turning on strictNullChecks
|
94
|
-
const { importNames } = answers;
|
95
|
-
const patterns = importNames.map((importName) => ({
|
96
|
-
importName,
|
97
|
-
patternId: importName.startsWith(importPrefix)
|
98
|
-
? importName.slice(importPrefix.length).toLowerCase()
|
99
|
-
: importName.toLowerCase(),
|
100
|
-
}));
|
101
|
-
return [
|
102
|
-
...patterns.map(({ importName, patternId }) => ({
|
103
|
-
title: `Add ${importName} React Template`,
|
104
|
-
task: async (__, subTask) => {
|
105
|
-
const initialDemo = {
|
106
|
-
type: 'data',
|
107
|
-
id: (0, utils_1.makeShortId)(),
|
108
|
-
title: 'Main',
|
109
|
-
patternId,
|
110
|
-
templateId: 'react',
|
111
|
-
data: {
|
112
|
-
props: {},
|
113
|
-
slots: {},
|
114
|
-
},
|
115
|
-
};
|
116
|
-
const pattern = createPatternData({
|
117
|
-
id: patternId,
|
118
|
-
importName,
|
119
|
-
pkgPath,
|
120
|
-
initialDemoId: initialDemo.id,
|
121
|
-
});
|
122
|
-
await Promise.all([
|
123
|
-
(0, ks_file_utils_1.writeDemo)({
|
124
|
-
dataDir,
|
125
|
-
demo: initialDemo,
|
126
|
-
}),
|
127
|
-
(0, ks_file_utils_1.writeKsPatternConfig)({
|
128
|
-
dataDir,
|
129
|
-
patternId,
|
130
|
-
data: pattern,
|
131
|
-
}),
|
132
|
-
]);
|
133
|
-
},
|
134
|
-
})),
|
135
|
-
{
|
136
|
-
title: `Updating Nav`,
|
137
|
-
task: async (__, subTask) => {
|
138
|
-
const { byId } = await (0, ks_file_utils_1.readKsNavConfig)({
|
139
|
-
dataDir,
|
140
|
-
});
|
141
|
-
// attempt to find a nav group to put patterns under
|
142
|
-
const componentsGroup = Object.values(byId).find(({ path, name, id }) => {
|
143
|
-
// we only want groups (i.e. not pages or patterns)
|
144
|
-
if (path)
|
145
|
-
return false;
|
146
|
-
if (name.toLowerCase() === 'patterns')
|
147
|
-
return true;
|
148
|
-
if (name.toLowerCase() === 'components')
|
149
|
-
return true;
|
150
|
-
return false;
|
151
|
-
});
|
152
|
-
await (0, ks_file_utils_1.addKsNavItems)({
|
153
|
-
dataDir,
|
154
|
-
navItems: patterns.map(({ patternId }) => ({
|
155
|
-
navId: patternId,
|
156
|
-
navPath: `/pattern/${patternId}`,
|
157
|
-
navParent: (componentsGroup === null || componentsGroup === void 0 ? void 0 : componentsGroup.id) || 'root',
|
158
|
-
})),
|
159
|
-
});
|
160
|
-
},
|
161
|
-
},
|
162
|
-
];
|
163
|
-
},
|
164
|
-
}),
|
165
|
-
}),
|
166
|
-
},
|
167
|
-
];
|
168
|
-
},
|
169
|
-
});
|
170
|
-
//# sourceMappingURL=react-creators.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"react-creators.js","sourceRoot":"","sources":["../src/react-creators.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AACxD,2DAAqE;AACrE,2DAMiC;AAEjC,2CAA8C;AAE9C,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC;AACrC,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAW;IAC1C,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,iBAAiB,CAAC,EACzB,UAAU,EACV,EAAE,EACF,KAAK,GAAG,UAAU,EAClB,OAAO,EACP,aAAa,GAOd;IACC,OAAO;QACL,EAAE;QACF,KAAK;QACL,WAAW,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