react-cosmos 6.2.4-canary.fa66419.0 → 7.0.0-beta.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/config.schema.json +2 -2
- package/dist/devServer/httpServer.js +0 -3
- package/dist/devServer/startDevServer.js +6 -4
- package/dist/export/generateExport.js +1 -1
- package/dist/shared/applyServerConfigPlugins.js +1 -1
- package/dist/shared/playgroundUrl.d.ts +1 -0
- package/dist/shared/playgroundUrl.js +4 -0
- package/dist/testHelpers/mockConsole.js +13 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
package/config.schema.json
CHANGED
|
@@ -174,8 +174,8 @@
|
|
|
174
174
|
"description": "Path to Vite config. Set to false to disable reading it from the default path. [default: \"vite.config.js\" or \"vite.config.ts\"]",
|
|
175
175
|
"anyOf": [{ "type": "string", "minLength": 1 }, { "enum": [false] }]
|
|
176
176
|
},
|
|
177
|
-
"
|
|
178
|
-
"description": "
|
|
177
|
+
"mainScriptUrl": {
|
|
178
|
+
"description": "URL to custom main script (eg. \"/src/my-main.tsx\"). [default: detect main script URL]",
|
|
179
179
|
"anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }]
|
|
180
180
|
},
|
|
181
181
|
"port": {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
2
|
import https from 'https';
|
|
3
|
-
import { getPlaygroundUrls } from '../shared/playgroundUrl.js';
|
|
4
3
|
import { getHttpsCreds } from './httpsCreds.js';
|
|
5
4
|
export async function createHttpServer(config, requestListener) {
|
|
6
5
|
const server = config.https
|
|
@@ -15,8 +14,6 @@ export async function createHttpServer(config, requestListener) {
|
|
|
15
14
|
server.listen(config.port, config.host, resolve);
|
|
16
15
|
}
|
|
17
16
|
});
|
|
18
|
-
const urls = getPlaygroundUrls(config);
|
|
19
|
-
console.log(`[Cosmos] See you at ${urls.join(' or ')}`);
|
|
20
17
|
}
|
|
21
18
|
async function stop() {
|
|
22
19
|
await new Promise(resolve => server.close(resolve));
|
|
@@ -4,6 +4,7 @@ import { getPluginConfigs } from '../cosmosPlugin/pluginConfigs.js';
|
|
|
4
4
|
import { applyServerConfigPlugins } from '../shared/applyServerConfigPlugins.js';
|
|
5
5
|
import { getServerPlugins } from '../shared/getServerPlugins.js';
|
|
6
6
|
import { logPluginInfo } from '../shared/logPluginInfo.js';
|
|
7
|
+
import { logPlaygroundUrls } from '../shared/playgroundUrl.js';
|
|
7
8
|
import { serveStaticDir } from '../shared/staticServer.js';
|
|
8
9
|
import { createExpressApp } from './expressApp.js';
|
|
9
10
|
import { createHttpServer } from './httpServer.js';
|
|
@@ -60,7 +61,7 @@ export async function startDevServer(platform) {
|
|
|
60
61
|
catch (err) {
|
|
61
62
|
// Log when a plugin fails to clean up, but continue to attempt
|
|
62
63
|
// to clean up the remaining plugins
|
|
63
|
-
console.log(`[Cosmos][
|
|
64
|
+
console.log(`[Cosmos][${plugin.name}] Dev server cleanup failed`);
|
|
64
65
|
console.log(err);
|
|
65
66
|
}
|
|
66
67
|
});
|
|
@@ -69,19 +70,20 @@ export async function startDevServer(platform) {
|
|
|
69
70
|
catch (err) {
|
|
70
71
|
// Abort starting server if a plugin init fails and attempt cleanup of all
|
|
71
72
|
// plugins that have already initialized
|
|
72
|
-
console.log(`[Cosmos][
|
|
73
|
+
console.log(`[Cosmos][${plugin.name}] Dev server init failed`);
|
|
73
74
|
cleanUp();
|
|
74
75
|
throw err;
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
logPlaygroundUrls(config);
|
|
77
79
|
return cleanUp;
|
|
78
80
|
}
|
|
79
81
|
function logCosmosConfigInfo() {
|
|
80
82
|
const cosmosConfigPath = detectCosmosConfigPath();
|
|
81
83
|
if (!cosmosConfigPath) {
|
|
82
|
-
console.log(`[Cosmos] Using default
|
|
84
|
+
console.log(`[Cosmos] Using default Cosmos config`);
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
87
|
const relConfigPath = path.relative(process.cwd(), cosmosConfigPath);
|
|
86
|
-
console.log(`[Cosmos] Using
|
|
88
|
+
console.log(`[Cosmos] Using config found at ${relConfigPath}`);
|
|
87
89
|
}
|
|
@@ -5,7 +5,7 @@ export async function applyServerConfigPlugins({ config, serverPlugins, mode, pl
|
|
|
5
5
|
config = await plugin.config({ config, mode, platform });
|
|
6
6
|
}
|
|
7
7
|
catch (err) {
|
|
8
|
-
console.log(`[Cosmos][
|
|
8
|
+
console.log(`[Cosmos][${plugin.name}] Config hook failed`);
|
|
9
9
|
throw err;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -9,3 +9,7 @@ export function getPlaygroundUrls(config) {
|
|
|
9
9
|
`${protocol}://${getServerHost(config)}:${config.port}`,
|
|
10
10
|
];
|
|
11
11
|
}
|
|
12
|
+
export function logPlaygroundUrls(config) {
|
|
13
|
+
const urls = getPlaygroundUrls(config);
|
|
14
|
+
console.log(`[Cosmos] See you at ${urls.join(' or ')}`);
|
|
15
|
+
}
|
|
@@ -7,10 +7,17 @@ export async function mockConsole(cb) {
|
|
|
7
7
|
origConsoleLog(...args);
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
try {
|
|
11
|
+
const cbReturn = await cb({
|
|
12
|
+
expectLog: (msg) => expectedLogs.push(msg),
|
|
13
|
+
});
|
|
14
|
+
expectedLogs.forEach(msg => expect(console.log).toBeCalledWith(msg));
|
|
15
|
+
return cbReturn;
|
|
16
|
+
}
|
|
17
|
+
catch (err) {
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
console.log = origConsoleLog;
|
|
22
|
+
}
|
|
16
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/client.ts","../src/index.ts","../src/vitest.ts","../src/@types/launch-editor.d.ts","../src/@types/mdx.d.ts","../src/@types/yargs.d.ts","../src/
|
|
1
|
+
{"root":["../src/client.ts","../src/index.ts","../src/vitest.ts","../src/@types/launch-editor.d.ts","../src/@types/mdx.d.ts","../src/@types/yargs.d.ts","../src/coreplugins/fixturewatcherplugin.ts","../src/coreplugins/fixturesjsonplugin.ts","../src/coreplugins/httpproxyplugin.ts","../src/coreplugins/index.ts","../src/coreplugins/openfileplugin.ts","../src/coreplugins/pluginendpointplugin.ts","../src/coreplugins/portretryplugin.ts","../src/coreplugins/remoterendererurlplugin.ts","../src/cosmosconfig/createcosmosconfig.ts","../src/cosmosconfig/detectcosmosconfig.ts","../src/cosmosconfig/getcosmosconfigatpath.ts","../src/cosmosconfig/shared.ts","../src/cosmosconfig/types.ts","../src/cosmosplugin/findcosmospluginconfigs.ts","../src/cosmosplugin/pluginconfigs.ts","../src/cosmosplugin/readcosmospluginconfig.ts","../src/cosmosplugin/types.ts","../src/devserver/expressapp.ts","../src/devserver/httpserver.ts","../src/devserver/httpscreds.ts","../src/devserver/messagehandler.ts","../src/devserver/startdevserver.ts","../src/export/generateexport.ts","../src/getfixtures/getfixtures.ts","../src/getfixtures/importusermodules.ts","../src/shared/applyserverconfigplugins.ts","../src/shared/findnextavailableport.ts","../src/shared/getserverplugins.ts","../src/shared/importserverplugins.ts","../src/shared/logplugininfo.ts","../src/shared/playgroundhtml.ts","../src/shared/playgroundurl.ts","../src/shared/remoterendererurl.ts","../src/shared/serveraddress.ts","../src/shared/serverfixturelist.ts","../src/shared/staticpath.ts","../src/shared/staticserver.ts","../src/shared/websocketurl.ts","../src/usermodules/findusermodulepaths.ts","../src/usermodules/fixturewatcher.ts","../src/usermodules/generateuserimports.ts","../src/usermodules/shared.ts","../src/usermodules/userimportslazytemplate.ts","../src/usermodules/userimportstemplate.ts","../src/utils/cli.ts","../src/utils/findup.ts","../src/utils/fs.ts","../src/utils/isnodeerror.ts","../src/utils/json.ts","../src/utils/requiremodule.ts","../src/utils/resolve.ts","../src/utils/resolveloose.ts","../src/utils/resolvesilent.ts","../src/utils/slash.ts"],"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.0",
|
|
4
4
|
"description": "Sandbox for developing and testing UI components in isolation",
|
|
5
5
|
"repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"chokidar": "3.6.0",
|
|
12
12
|
"express": "4.21.2",
|
|
13
13
|
"glob": "10.4.5",
|
|
14
|
-
"http-proxy-middleware": "2.0.
|
|
14
|
+
"http-proxy-middleware": "2.0.9",
|
|
15
15
|
"lodash-es": "4.17.21",
|
|
16
16
|
"micromatch": "4.0.8",
|
|
17
|
-
"open": "10.1.
|
|
17
|
+
"open": "10.1.1",
|
|
18
18
|
"pem": "1.15.1",
|
|
19
|
-
"react-cosmos-core": "
|
|
20
|
-
"react-cosmos-renderer": "
|
|
21
|
-
"react-cosmos-ui": "
|
|
22
|
-
"ws": "8.18.
|
|
19
|
+
"react-cosmos-core": "7.0.0-beta.0",
|
|
20
|
+
"react-cosmos-renderer": "7.0.0-beta.0",
|
|
21
|
+
"react-cosmos-ui": "7.0.0-beta.0",
|
|
22
|
+
"ws": "8.18.1",
|
|
23
23
|
"yargs": "17.7.2"
|
|
24
24
|
},
|
|
25
25
|
"bin": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"cosmos-export": "./bin/cosmos-export.js",
|
|
28
28
|
"cosmos-native": "./bin/cosmos-native.js"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "c01fecbf8b3342846f24d5860bf2d5146801ae3e"
|
|
31
31
|
}
|