create-zephyr-apps 0.0.7 → 0.0.39

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/package/index.ts DELETED
@@ -1,191 +0,0 @@
1
- #!/usr/bin/env node
2
- import { setTimeout } from 'node:timers/promises';
3
- import { exec } from 'node:child_process';
4
- import end_note from './utils/end'
5
- import {
6
- spinner,
7
- group,
8
- intro,
9
- outro,
10
- isCancel,
11
- password,
12
- cancel,
13
- text,
14
- note,
15
- confirm,
16
- select,
17
- multiselect,
18
- tasks,
19
- log,
20
- updateSettings,
21
- } from '@clack/prompts';
22
- import c from "chalk";
23
- import { TEMPLATES } from './utils/constants';
24
- import { CLIOptions } from './utils/types';
25
- import * as tempy from 'tempy';
26
- import path from 'path';
27
- import * as fs from 'node:fs'
28
-
29
-
30
- async function main() {
31
- console.clear();
32
-
33
- await setTimeout(1000);
34
-
35
- updateSettings({
36
- aliases: {
37
- w: 'up',
38
- s: 'down',
39
- a: 'left',
40
- d: 'right',
41
- },
42
- });
43
-
44
- note('npx create-zephyr-apps@latest');
45
- intro(`${c.bgCyan(c.black(' Create federated applications with Zephyr '))}`);
46
-
47
- const project = await group(
48
- {
49
- path: ({ results }) => {
50
- return text({
51
- message: 'Where should we create your project?',
52
- placeholder: './sparkling-solid',
53
- validate: value => {
54
- if (!value) return 'Please enter a path.';
55
- if (value[0] !== '.') return 'Please enter a relative path.';
56
- },
57
- });
58
- },
59
-
60
- type: () =>
61
- select({
62
- message: 'What type of project you are creating?',
63
- initialValue: 'web',
64
- options: [
65
- {
66
- value: 'web',
67
- label: 'Web',
68
- hint: 'You will be choosing from a selection of templates provided by us.',
69
- },
70
- {
71
- value: 'react-native',
72
- label: 'React Native',
73
- hint: 'This is a comprehensive example project provided by us. You will be building React Native powered by Re.Pack.',
74
- },
75
- ],
76
- }),
77
-
78
- templates: ({ results }) => {
79
-
80
- if (results.type === 'web') {
81
- return select({
82
- message: 'Pick a template: ',
83
- initialValue: 'react-rspack-mf',
84
- maxItems: 5,
85
- options: Object.keys(TEMPLATES).map((template) => {
86
- return {
87
- value: template as keyof typeof TEMPLATES,
88
- label: c.cyan(TEMPLATES[template as keyof typeof TEMPLATES].label),
89
- hint: TEMPLATES[template as keyof typeof TEMPLATES].hint
90
- }
91
- })
92
- })
93
- }
94
- },
95
-
96
- },
97
- {
98
- onCancel: () => {
99
- cancel('Operation cancelled.');
100
- process.exit(0);
101
- },
102
- },
103
- ) as CLIOptions;
104
-
105
-
106
-
107
- const temp_dir = tempy.temporaryDirectory()
108
-
109
- const command_web = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-examples.git -b main ${temp_dir}`
110
- const command_react_native = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-repack-example.git -b main ${temp_dir}`
111
-
112
- const project_path = project.path.replace('./', '').trim()
113
-
114
- const s = spinner()
115
- s.start(c.cyan(`Creating project in ${project_path}`))
116
- if (project.type === 'web') {
117
-
118
-
119
- exec(command_web, async (err, stdout, stderr) => {
120
-
121
- if (err) {
122
- s.stop(c.bgRed(c.black(`Error cloning ${command_web} to ${project_path}...`)))
123
- console.error(err);
124
- process.exit(0);
125
-
126
- }
127
-
128
- if (!err) {
129
- const outputPath = path.join(process.cwd(), project.path);
130
-
131
- const clonedPath = path.join(temp_dir, 'examples', project.templates as string)
132
-
133
- try {
134
- const result2 = await fs.promises.cp(clonedPath, outputPath, {
135
- recursive: true,
136
- force: true
137
- });
138
-
139
- s.stop(c.green(`Project successfully created at ${c.underline(project_path)}`))
140
-
141
- } catch (error) {
142
- console.error(c.bgRed(c.black(`Error cloning to ${project_path}...`)))
143
- console.error(error)
144
- process.exit(2)
145
- } finally {
146
- await fs.promises.rm(temp_dir, { recursive: true, force: true })
147
- end_note({ project })
148
- }
149
- }
150
- })
151
-
152
- }
153
-
154
-
155
- if (project.type === 'react-native') {
156
-
157
-
158
- exec(command_react_native, async (err, stdout, stderr) => {
159
- if (err) {
160
- s.stop(c.bgRed(c.black(`Error cloning to ${project_path}...`)))
161
- console.error(err)
162
- process.exit(2)
163
- }
164
-
165
- if (!err) {
166
-
167
- const outputPath = path.join(process.cwd(), project.path);
168
- try {
169
- const result2 = await fs.promises.cp(temp_dir, outputPath, {
170
- recursive: true,
171
- force: true
172
- });
173
- s.stop(c.green(`Project successfully created at ${c.underline(project_path)}`))
174
- } catch (error) {
175
- s.stop(c.bgRed(c.black(`Error clonin to ${project_path}`)))
176
- console.error(error)
177
- process.exit(2)
178
- } finally {
179
- await fs.promises.rm(temp_dir, { recursive: true, force: true })
180
- end_note({ project })
181
- }
182
-
183
- }
184
- })
185
- }
186
-
187
-
188
- }
189
-
190
- main().catch(console.error);
191
-
@@ -1,68 +0,0 @@
1
- const REPO_OWNER = 'ZephyrCloudIO';
2
- const REPO_NAME = 'zephyr-examples';
3
- const REPACK_REPO = 'zephyr-repack-example';
4
-
5
- const BASE_REPO = `${REPO_OWNER}/${REPO_NAME}`;
6
-
7
- const REPACK_REPO_PATH = `${REPO_OWNER}/${REPACK_REPO}`;
8
-
9
-
10
- const TEMPLATES = {
11
- 'rspack-project': {
12
- label: 'React + Rspack',
13
- hint: 'A simple application build by Rspack.',
14
- framework: 'react'
15
- },
16
- 'react-vite-ts': {
17
- label: 'A simple React application build by Vite',
18
- hint: 'You will be building React app powered by Vite.',
19
- framework: 'react'
20
- },
21
- 'react-vite-mf': {
22
- label: 'React + Vite + Webpack + Rspack',
23
- hint: 'You will be building federated React apps powered by Vite, Webpack and Rspack.',
24
- framework: 'react'
25
- },
26
- 'angular-vite': {
27
- label: 'Angular app with Vite',
28
- hint: 'You will be building an Angular app powered by Vite.',
29
- framework: 'angular'
30
- },
31
- 'react-webpack-mf': {
32
- label: 'React + Webpack',
33
- hint: 'A React application with Module Federation, using Webpack as the bundler.',
34
- framework: 'react'
35
- },
36
- 'nx-rspack-mf': {
37
- label: 'React + Nx + Rspack',
38
- hint: 'A React application with Module Federation, using Nx as Monorepo manager and Rspack as the bundler.',
39
- framework: 'react'
40
- },
41
- 'nx-webpack-mf': {
42
- label: 'React + Nx + Webpack',
43
- hint: 'React applications with Module Federation, using Nx as Monorepo manager and Webpack as the bundler.',
44
- framework: 'react'
45
- },
46
- 'ng-nx': {
47
- label: 'Angular app with Nx',
48
- hint: 'An Angular application with Nx as Monorepo manager.',
49
- framework: 'angular'
50
- },
51
- 'qwik-1.5': {
52
- label: 'Qwik + Vite',
53
- hint: 'A Qwik v1.5 app using Vite as the bundler.',
54
- framework: 'qwik'
55
- },
56
- 'react-rspack-tractor-2.0': {
57
- label: 'React + Rspack + Tractor 2.0',
58
- hint: 'A React application using Rspack as the bundler and Tractor 2.0 as the module federation manager.',
59
- framework: 'react'
60
- },
61
- 'turbo-rspack-mf': {
62
- label: 'Turbo + Rspack + Module Federation',
63
- hint: 'A monorepo using Turborepo, React, and Rspack as the bundler.',
64
- framework: 'react'
65
- }
66
- }
67
-
68
- export { REPO_OWNER, REPO_NAME, REPACK_REPO, BASE_REPO, REPACK_REPO_PATH, TEMPLATES };
@@ -1,56 +0,0 @@
1
- import { CLIOptions } from './types';
2
- import c from 'chalk';
3
- import { exec } from 'child_process';
4
- import { note } from '@clack/prompts';
5
-
6
- export default function end_note({ project }: { project: CLIOptions }) {
7
- try {
8
- exec(`git config user.name`, (err, stdout, stderr) => {
9
- const user_name = stdout.toString().trim();
10
-
11
- const repo_name = project.path.split('/').pop();
12
-
13
- let next_steps;
14
-
15
- if (project.type === 'web') {
16
- next_steps = [
17
- `cd ${repo_name}`,
18
- `pnpm install`,
19
- `rm -rf .git`,
20
- `git init`,
21
- `git remote add origin https://github.com/${user_name.length >= 1 ? user_name : 'YourUsername'}/${repo_name}.git`,
22
- `git add .`,
23
- `git commit -m "Initial commit"`,
24
- `pnpm run build`,
25
- ];
26
- } else {
27
- next_steps = [
28
- `cd ${repo_name}`,
29
- `pnpm install`,
30
- `rm -rf .git`,
31
- `git init`,
32
- c.magenta(`git remote add origin https://github.com/${user_name.length >= 1 ? user_name : 'YourUsername'}/${repo_name}.git`),
33
- `git add .`,
34
- `git commit -m "Initial commit"`,
35
- `ZC=1 pnpm run start`,
36
- `\n--------------------------------\n`,
37
- `Make your first commit and link it to the remote repository!`,
38
- `Read more about how Module Federation works with Zephyr and why steps above are required: ${c.underline(c.cyan('https://docs.zephyr-cloud.io/how-to/mf-guide'))}`,
39
- ];
40
- }
41
-
42
- note(c.cyan(next_steps.join('\n')), 'Next steps.');
43
- });
44
- } catch (error) {
45
- console.error(error);
46
- } finally {
47
- const end_notes = [
48
- `Discord: ${c.underline(c.cyan('https://zephyr-cloud.io/discord'))}`,
49
- `Documentation: ${project.type === 'web' ? c.underline(c.cyan('https://docs.zephyr-cloud.io/recipes')) : c.underline(c.cyan('https://docs.zephyr-cloud.io/recipes/repack-mf'))}`,
50
- `Open an issue: ${c.underline(c.cyan('https://github.com/ZephyrCloudIO/create-zephyr-apps/issues'))}`,
51
- ];
52
-
53
- note(Object.values(end_notes).join('\n'), 'Problems?');
54
- }
55
- }
56
-
@@ -1,32 +0,0 @@
1
- export interface GithubTreeItem {
2
- path: string;
3
- type: 'tree' | 'blob';
4
- }
5
-
6
- export interface ExampleMetadata {
7
- name: string;
8
- description: string;
9
- path: string;
10
- }
11
-
12
- export interface WebCreationOptions {
13
- path: string;
14
- template: string;
15
- framework: string;
16
- }
17
-
18
- export interface ReactNativeCreationOptions {
19
- path: string;
20
- // host_name: string;
21
- // remote_names: string[];
22
- }
23
-
24
- export interface CLIOptions {
25
- path: string;
26
- type: 'web' | 'react-native';
27
- /** At the moment, if users opt for web they will only be asked for a template without host name and remote_name */
28
- templates: string | undefined;
29
- //host_name: string | undefined;
30
- //remote_names: string[] | undefined;
31
- install: boolean;
32
- }
package/rslib.config.ts DELETED
@@ -1,42 +0,0 @@
1
- import { defineConfig } from '@rslib/core';
2
-
3
- export default defineConfig({
4
- source: {
5
- entry: {
6
- index: './package/index.ts',
7
- }
8
- },
9
- lib: [
10
- {
11
- format: 'cjs',
12
- autoExtension: false,
13
- syntax: 'es2020',
14
- dts: {
15
- build: true,
16
- },
17
- output: {
18
- target: 'node',
19
- filename: {
20
- js: '[name].cjs',
21
- },
22
- cleanDistPath: true,
23
- },
24
- },
25
- {
26
- format: 'esm',
27
- autoExtension: false,
28
- syntax: 'es2020',
29
- dts: {
30
- build: true,
31
- },
32
- output: {
33
- target: 'node',
34
- filename: {
35
- js: '[name].mjs',
36
- },
37
- cleanDistPath: true,
38
- },
39
- }
40
- ],
41
-
42
- });
package/tsconfig.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Enable latest features
4
- "lib": ["ESNext"],
5
- "target": "ES2020",
6
- "module": "ES2020",
7
- "moduleDetection": "force",
8
-
9
- //"jsx": "react-jsx",
10
- "allowJs": true,
11
-
12
- // Bundler mode
13
- "moduleResolution": "bundler",
14
- "allowSyntheticDefaultImports": true,
15
- "allowImportingTsExtensions": true,
16
- //"verbatimModuleSyntax": true,
17
- "noEmit": true,
18
-
19
- // Best practices
20
- "strict": true,
21
- "skipLibCheck": true,
22
- "noFallthroughCasesInSwitch": true,
23
-
24
- // Some stricter flags (disabled by default)
25
- "noUnusedLocals": false,
26
- "noUnusedParameters": false,
27
- "noPropertyAccessFromIndexSignature": false,
28
- "outDir": "./dist",
29
- "types": ["node"]
30
- }
31
- }
File without changes