svelte-realtime 0.4.1 → 0.4.3
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/cli.js +19 -20
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -83,45 +83,39 @@ if (p.isCancel(template)) {
|
|
|
83
83
|
const agent = detectAgent(process.env.npm_config_user_agent);
|
|
84
84
|
|
|
85
85
|
if (template === 'demo') {
|
|
86
|
-
|
|
87
|
-
s.start('Cloning demo repository');
|
|
86
|
+
p.log.step('Cloning demo repository');
|
|
88
87
|
run(`git clone ${DEMO_REPO} "${name}"`);
|
|
89
|
-
s.stop('Cloned.');
|
|
90
88
|
|
|
91
|
-
|
|
89
|
+
p.log.step('Installing dependencies');
|
|
92
90
|
run(`${agent} install`, dest);
|
|
93
|
-
s.stop('Installed.');
|
|
94
91
|
|
|
95
92
|
p.outro(`Done. cd ${name} && ${agent} run dev`);
|
|
96
93
|
process.exit(0);
|
|
97
94
|
}
|
|
98
95
|
|
|
99
|
-
|
|
96
|
+
p.log.step('Creating SvelteKit project');
|
|
97
|
+
run(`npx -y sv create "${name}" --template minimal --types ts --no-add-ons --no-install`);
|
|
100
98
|
|
|
101
|
-
|
|
102
|
-
run(`npx -y sv create "${name}" --template minimal --types ts`);
|
|
103
|
-
s.stop('Project created.');
|
|
104
|
-
|
|
105
|
-
s.start('Installing dependencies');
|
|
99
|
+
p.log.step('Installing dependencies');
|
|
106
100
|
const add = agent === 'npm' ? 'install' : 'add';
|
|
107
101
|
run(`${agent} ${add} svelte-adapter-uws svelte-realtime`, dest);
|
|
108
102
|
run(`${agent} ${add} uNetworking/uWebSockets.js#v20.60.0`, dest);
|
|
109
103
|
run(`${agent} ${add} -D ws`, dest);
|
|
110
|
-
s.stop('Dependencies installed.');
|
|
111
104
|
|
|
112
|
-
|
|
105
|
+
p.log.step('Configuring svelte-realtime');
|
|
113
106
|
|
|
114
107
|
writeFileSync(
|
|
115
108
|
join(dest, 'svelte.config.js'),
|
|
116
109
|
`import adapter from 'svelte-adapter-uws';
|
|
117
|
-
import { vitePreprocess } from '@sveltejs/kit/vite';
|
|
118
110
|
|
|
119
|
-
|
|
111
|
+
/** @type {import('@sveltejs/kit').Config} */
|
|
112
|
+
const config = {
|
|
120
113
|
\tkit: {
|
|
121
114
|
\t\tadapter: adapter({ websocket: true })
|
|
122
|
-
\t}
|
|
123
|
-
\tpreprocess: [vitePreprocess()]
|
|
115
|
+
\t}
|
|
124
116
|
};
|
|
117
|
+
|
|
118
|
+
export default config;
|
|
125
119
|
`
|
|
126
120
|
);
|
|
127
121
|
|
|
@@ -189,17 +183,22 @@ export const counter = live.stream('count', () => {
|
|
|
189
183
|
);
|
|
190
184
|
}
|
|
191
185
|
|
|
192
|
-
|
|
186
|
+
p.log.success('Configured.');
|
|
193
187
|
|
|
194
188
|
p.outro(`Done. cd ${name} && ${agent} run dev`);
|
|
195
189
|
|
|
196
190
|
// ---------------------------------------------------------------------------
|
|
197
191
|
|
|
192
|
+
/** @param {string} cmd @param {string} [cwd] */
|
|
198
193
|
function run(cmd, cwd) {
|
|
199
194
|
try {
|
|
200
|
-
execSync(cmd, {
|
|
195
|
+
execSync(cmd, {
|
|
196
|
+
cwd,
|
|
197
|
+
stdio: 'inherit',
|
|
198
|
+
env: { ...process.env, NODE_ENV: undefined }
|
|
199
|
+
});
|
|
201
200
|
} catch (e) {
|
|
202
|
-
p.cancel(`Command failed: ${cmd}\n${e.stderr || e.message}`);
|
|
201
|
+
p.cancel(`Command failed: ${cmd}\n${/** @type {any} */ (e).stderr || /** @type {any} */ (e).message}`);
|
|
203
202
|
process.exit(1);
|
|
204
203
|
}
|
|
205
204
|
}
|