create-zephyr-apps 0.0.0 → 0.0.2
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/.nvmrc +1 -0
- package/LICENSE +201 -0
- package/README.md +18 -0
- package/dist/index.cjs +250 -0
- package/dist/index.mjs +214 -0
- package/dist/package/index.d.ts +2 -0
- package/dist/package/utils/constants.d.ts +63 -0
- package/dist/package/utils/end.d.ts +4 -0
- package/dist/package/utils/types.d.ts +24 -0
- package/dist/rslib.config.d.ts +2 -0
- package/package/index.ts +191 -0
- package/package/utils/constants.ts +68 -0
- package/package/utils/end.ts +37 -0
- package/package/utils/types.ts +32 -0
- package/package.json +45 -7
- package/rslib.config.ts +42 -0
- package/tsconfig.json +31 -0
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# create-zephyr-apps
|
|
2
|
+
|
|
3
|
+
Recommend using node version 22.0.0 or above.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npx create-zephyr-apps@latest
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Todos
|
|
10
|
+
|
|
11
|
+
- [ ] Move templates generation to local or using normal vite/rspack/react-native generation command
|
|
12
|
+
- [ ] Add bundling options
|
|
13
|
+
- [ ] Creating template file to make sure dependencies are up to date
|
|
14
|
+
- [ ] Add Nx as an option for monorepo
|
|
15
|
+
- [ ] Add package manager selector
|
|
16
|
+
- [ ] Add tests
|
|
17
|
+
- [ ] Add more documentation
|
|
18
|
+
- [ ] Write a good readme
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.n = function(module) {
|
|
6
|
+
var getter = module && module.__esModule ? function() {
|
|
7
|
+
return module['default'];
|
|
8
|
+
} : function() {
|
|
9
|
+
return module;
|
|
10
|
+
};
|
|
11
|
+
__webpack_require__.d(getter, {
|
|
12
|
+
a: getter
|
|
13
|
+
});
|
|
14
|
+
return getter;
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
19
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: definition[key]
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
(()=>{
|
|
26
|
+
__webpack_require__.o = function(obj, prop) {
|
|
27
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
28
|
+
};
|
|
29
|
+
})();
|
|
30
|
+
var __webpack_exports__ = {};
|
|
31
|
+
const promises_namespaceObject = require("node:timers/promises");
|
|
32
|
+
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
33
|
+
const external_chalk_namespaceObject = require("chalk");
|
|
34
|
+
var external_chalk_default = /*#__PURE__*/ __webpack_require__.n(external_chalk_namespaceObject);
|
|
35
|
+
const external_child_process_namespaceObject = require("child_process");
|
|
36
|
+
const prompts_namespaceObject = require("@clack/prompts");
|
|
37
|
+
function end_note({ project }) {
|
|
38
|
+
try {
|
|
39
|
+
(0, external_child_process_namespaceObject.exec)(`${project.path} && git config user.name`, (err, stdout, stderr)=>{
|
|
40
|
+
console.log(stdout);
|
|
41
|
+
const user_name = stdout.toString().trim();
|
|
42
|
+
const repo_name = project.path.split('/').pop();
|
|
43
|
+
let next_steps;
|
|
44
|
+
next_steps = 'web' === project.type ? `cd ${repo_name} \npnpm install\ngit remote add origin https://github.com/${user_name ?? 'YourUsername'}/${repo_name}.git\npnpm run build` : `cd ${repo_name} \npnpm install\nrm -rf .git\ngit remote set origin https://github.com/${user_name ?? 'YourUsername'}/${repo_name}.git\npnpm run build`;
|
|
45
|
+
(0, prompts_namespaceObject.note)(next_steps, 'Next steps.');
|
|
46
|
+
});
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error(error);
|
|
49
|
+
} finally{
|
|
50
|
+
const end_notes = [
|
|
51
|
+
`Discord: ${external_chalk_default().underline(external_chalk_default().cyan('https://zephyr-cloud.io/discord'))}`,
|
|
52
|
+
`Documentation: ${external_chalk_default().underline(external_chalk_default().cyan('https://zephyr-cloud.io/docs'))}`,
|
|
53
|
+
`Open an issue: ${external_chalk_default().underline(external_chalk_default().cyan('https://github.com/ZephyrCloudIO/create-zephyr-apps/issues'))}`
|
|
54
|
+
];
|
|
55
|
+
(0, prompts_namespaceObject.note)(Object.values(end_notes).join('\n'), 'Problems?');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const TEMPLATES = {
|
|
59
|
+
'rspack-project': {
|
|
60
|
+
label: 'React + Rspack',
|
|
61
|
+
hint: 'A simple application build by Rspack.',
|
|
62
|
+
framework: 'react'
|
|
63
|
+
},
|
|
64
|
+
'react-vite-ts': {
|
|
65
|
+
label: 'A simple React application build by Vite',
|
|
66
|
+
hint: 'You will be building React app powered by Vite.',
|
|
67
|
+
framework: 'react'
|
|
68
|
+
},
|
|
69
|
+
'react-vite-mf': {
|
|
70
|
+
label: 'React + Vite + Webpack + Rspack',
|
|
71
|
+
hint: 'You will be building federated React apps powered by Vite, Webpack and Rspack.',
|
|
72
|
+
framework: 'react'
|
|
73
|
+
},
|
|
74
|
+
'angular-vite': {
|
|
75
|
+
label: 'Angular app with Vite',
|
|
76
|
+
hint: 'You will be building an Angular app powered by Vite.',
|
|
77
|
+
framework: 'angular'
|
|
78
|
+
},
|
|
79
|
+
'react-webpack-mf': {
|
|
80
|
+
label: 'React + Webpack',
|
|
81
|
+
hint: 'A React application with Module Federation, using Webpack as the bundler.',
|
|
82
|
+
framework: 'react'
|
|
83
|
+
},
|
|
84
|
+
'nx-rspack-mf': {
|
|
85
|
+
label: 'React + Nx + Rspack',
|
|
86
|
+
hint: 'A React application with Module Federation, using Nx as Monorepo manager and Rspack as the bundler.',
|
|
87
|
+
framework: 'react'
|
|
88
|
+
},
|
|
89
|
+
'nx-webpack-mf': {
|
|
90
|
+
label: 'React + Nx + Webpack',
|
|
91
|
+
hint: 'React applications with Module Federation, using Nx as Monorepo manager and Webpack as the bundler.',
|
|
92
|
+
framework: 'react'
|
|
93
|
+
},
|
|
94
|
+
'ng-nx': {
|
|
95
|
+
label: 'Angular app with Nx',
|
|
96
|
+
hint: 'An Angular application with Nx as Monorepo manager.',
|
|
97
|
+
framework: 'angular'
|
|
98
|
+
},
|
|
99
|
+
'qwik-1.5': {
|
|
100
|
+
label: 'Qwik + Vite',
|
|
101
|
+
hint: 'A Qwik v1.5 app using Vite as the bundler.',
|
|
102
|
+
framework: 'qwik'
|
|
103
|
+
},
|
|
104
|
+
'react-rspack-tractor-2.0': {
|
|
105
|
+
label: 'React + Rspack + Tractor 2.0',
|
|
106
|
+
hint: 'A React application using Rspack as the bundler and Tractor 2.0 as the module federation manager.',
|
|
107
|
+
framework: 'react'
|
|
108
|
+
},
|
|
109
|
+
'turbo-rspack-mf': {
|
|
110
|
+
label: 'Turbo + Rspack + Module Federation',
|
|
111
|
+
hint: 'A monorepo using Turborepo, React, and Rspack as the bundler.',
|
|
112
|
+
framework: 'react'
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const external_tempy_namespaceObject = require("tempy");
|
|
116
|
+
const external_path_namespaceObject = require("path");
|
|
117
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
118
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
119
|
+
async function main() {
|
|
120
|
+
console.clear();
|
|
121
|
+
await (0, promises_namespaceObject.setTimeout)(1000);
|
|
122
|
+
(0, prompts_namespaceObject.updateSettings)({
|
|
123
|
+
aliases: {
|
|
124
|
+
w: 'up',
|
|
125
|
+
s: 'down',
|
|
126
|
+
a: 'left',
|
|
127
|
+
d: 'right'
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
(0, prompts_namespaceObject.note)('npx create-zephyr-apps@latest');
|
|
131
|
+
(0, prompts_namespaceObject.intro)(`${external_chalk_default().bgCyan(external_chalk_default().black(' Create federated applications with Zephyr '))}`);
|
|
132
|
+
const project = await (0, prompts_namespaceObject.group)({
|
|
133
|
+
path: ({ results })=>(0, prompts_namespaceObject.text)({
|
|
134
|
+
message: 'Where should we create your project?',
|
|
135
|
+
placeholder: './sparkling-solid',
|
|
136
|
+
validate: (value)=>{
|
|
137
|
+
if (!value) return 'Please enter a path.';
|
|
138
|
+
if ('.' !== value[0]) return 'Please enter a relative path.';
|
|
139
|
+
}
|
|
140
|
+
}),
|
|
141
|
+
type: ()=>(0, prompts_namespaceObject.select)({
|
|
142
|
+
message: 'What type of project you are creating?',
|
|
143
|
+
initialValue: 'web',
|
|
144
|
+
options: [
|
|
145
|
+
{
|
|
146
|
+
value: 'web',
|
|
147
|
+
label: 'Web'
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
value: 'react-native',
|
|
151
|
+
label: 'React Native',
|
|
152
|
+
hint: 'You will be building React Native powered by Re.Pack.'
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}),
|
|
156
|
+
templates: ({ results })=>{
|
|
157
|
+
if ('web' === results.type) return (0, prompts_namespaceObject.select)({
|
|
158
|
+
message: 'Pick a template: ',
|
|
159
|
+
initialValue: 'react-rspack-mf',
|
|
160
|
+
maxItems: 5,
|
|
161
|
+
options: Object.keys(TEMPLATES).map((template)=>({
|
|
162
|
+
value: template,
|
|
163
|
+
label: external_chalk_default().cyan(TEMPLATES[template].label),
|
|
164
|
+
hint: TEMPLATES[template].hint
|
|
165
|
+
}))
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
onCancel: ()=>{
|
|
170
|
+
(0, prompts_namespaceObject.cancel)('Operation cancelled.');
|
|
171
|
+
process.exit(0);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
const temp_dir = external_tempy_namespaceObject.temporaryDirectory();
|
|
175
|
+
const command_web = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-examples.git -b main ${temp_dir}`;
|
|
176
|
+
const command_react_native = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-repack-example.git -b main ${temp_dir}`;
|
|
177
|
+
const project_path = project.path.replace('./', '').trim();
|
|
178
|
+
const s = (0, prompts_namespaceObject.spinner)();
|
|
179
|
+
if ('web' === project.type) {
|
|
180
|
+
s.start(external_chalk_default().cyan('Cloning subfolder ' + external_chalk_default().green(project.templates) + ' from repository https://github.com/ZephyrCloudIO/zephyr-examples.git'));
|
|
181
|
+
(0, external_node_child_process_namespaceObject.exec)(command_web, async (err, stdout, stderr)=>{
|
|
182
|
+
if (err) {
|
|
183
|
+
s.stop(external_chalk_default().bgRed(external_chalk_default().black(`Error cloning ${command_web} to ${project_path}...`)));
|
|
184
|
+
console.error(err);
|
|
185
|
+
process.exit(0);
|
|
186
|
+
}
|
|
187
|
+
if (!err) {
|
|
188
|
+
const outputPath = external_path_default().join(process.cwd(), project.path);
|
|
189
|
+
const clonedPath = external_path_default().join(temp_dir, 'examples', project.templates);
|
|
190
|
+
try {
|
|
191
|
+
await external_node_fs_namespaceObject.promises.cp(clonedPath, outputPath, {
|
|
192
|
+
recursive: true,
|
|
193
|
+
force: true
|
|
194
|
+
});
|
|
195
|
+
s.stop(external_chalk_default().green(`Project successfully created at ${external_chalk_default().underline(project_path)}`));
|
|
196
|
+
} catch (error) {
|
|
197
|
+
console.error(external_chalk_default().bgRed(external_chalk_default().black(`Error cloning to ${project_path}...`)));
|
|
198
|
+
console.error(error);
|
|
199
|
+
process.exit(2);
|
|
200
|
+
} finally{
|
|
201
|
+
await external_node_fs_namespaceObject.promises.rm(temp_dir, {
|
|
202
|
+
recursive: true,
|
|
203
|
+
force: true
|
|
204
|
+
});
|
|
205
|
+
end_note({
|
|
206
|
+
project
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if ('react-native' === project.type) {
|
|
213
|
+
s.start(external_chalk_default().cyan("Cloning repository https://github.com/ZephyrCloudIO/zephyr-repack-example.git"));
|
|
214
|
+
(0, external_node_child_process_namespaceObject.exec)(command_react_native, async (err, stdout, stderr)=>{
|
|
215
|
+
if (err) {
|
|
216
|
+
s.stop(external_chalk_default().bgRed(external_chalk_default().black(`Error cloning to ${project_path}...`)));
|
|
217
|
+
console.error(err);
|
|
218
|
+
process.exit(2);
|
|
219
|
+
}
|
|
220
|
+
if (!err) {
|
|
221
|
+
const outputPath = external_path_default().join(process.cwd(), project.path);
|
|
222
|
+
try {
|
|
223
|
+
await external_node_fs_namespaceObject.promises.cp(temp_dir, outputPath, {
|
|
224
|
+
recursive: true,
|
|
225
|
+
force: true
|
|
226
|
+
});
|
|
227
|
+
s.stop(external_chalk_default().green(`Project successfully created at ${external_chalk_default().underline(project_path)}`));
|
|
228
|
+
} catch (error) {
|
|
229
|
+
s.stop(external_chalk_default().bgRed(external_chalk_default().black(`Error clonin to ${project_path}`)));
|
|
230
|
+
console.error(error);
|
|
231
|
+
process.exit(2);
|
|
232
|
+
} finally{
|
|
233
|
+
await external_node_fs_namespaceObject.promises.rm(temp_dir, {
|
|
234
|
+
recursive: true,
|
|
235
|
+
force: true
|
|
236
|
+
});
|
|
237
|
+
end_note({
|
|
238
|
+
project
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
main().catch(console.error);
|
|
246
|
+
var __webpack_export_target__ = exports;
|
|
247
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
248
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
249
|
+
value: true
|
|
250
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_timers_promises_aedbf14c__ from "node:timers/promises";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__ from "node:child_process";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_chalk__ from "chalk";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE_child_process__ from "child_process";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__ from "@clack/prompts";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE_tempy__ from "tempy";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
10
|
+
function end_note({ project }) {
|
|
11
|
+
try {
|
|
12
|
+
(0, __WEBPACK_EXTERNAL_MODULE_child_process__.exec)(`${project.path} && git config user.name`, (err, stdout, stderr)=>{
|
|
13
|
+
console.log(stdout);
|
|
14
|
+
const user_name = stdout.toString().trim();
|
|
15
|
+
const repo_name = project.path.split('/').pop();
|
|
16
|
+
let next_steps;
|
|
17
|
+
next_steps = 'web' === project.type ? `cd ${repo_name} \npnpm install\ngit remote add origin https://github.com/${user_name ?? 'YourUsername'}/${repo_name}.git\npnpm run build` : `cd ${repo_name} \npnpm install\nrm -rf .git\ngit remote set origin https://github.com/${user_name ?? 'YourUsername'}/${repo_name}.git\npnpm run build`;
|
|
18
|
+
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.note)(next_steps, 'Next steps.');
|
|
19
|
+
});
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error(error);
|
|
22
|
+
} finally{
|
|
23
|
+
const end_notes = [
|
|
24
|
+
`Discord: ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan('https://zephyr-cloud.io/discord'))}`,
|
|
25
|
+
`Documentation: ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan('https://zephyr-cloud.io/docs'))}`,
|
|
26
|
+
`Open an issue: ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan('https://github.com/ZephyrCloudIO/create-zephyr-apps/issues'))}`
|
|
27
|
+
];
|
|
28
|
+
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.note)(Object.values(end_notes).join('\n'), 'Problems?');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const TEMPLATES = {
|
|
32
|
+
'rspack-project': {
|
|
33
|
+
label: 'React + Rspack',
|
|
34
|
+
hint: 'A simple application build by Rspack.',
|
|
35
|
+
framework: 'react'
|
|
36
|
+
},
|
|
37
|
+
'react-vite-ts': {
|
|
38
|
+
label: 'A simple React application build by Vite',
|
|
39
|
+
hint: 'You will be building React app powered by Vite.',
|
|
40
|
+
framework: 'react'
|
|
41
|
+
},
|
|
42
|
+
'react-vite-mf': {
|
|
43
|
+
label: 'React + Vite + Webpack + Rspack',
|
|
44
|
+
hint: 'You will be building federated React apps powered by Vite, Webpack and Rspack.',
|
|
45
|
+
framework: 'react'
|
|
46
|
+
},
|
|
47
|
+
'angular-vite': {
|
|
48
|
+
label: 'Angular app with Vite',
|
|
49
|
+
hint: 'You will be building an Angular app powered by Vite.',
|
|
50
|
+
framework: 'angular'
|
|
51
|
+
},
|
|
52
|
+
'react-webpack-mf': {
|
|
53
|
+
label: 'React + Webpack',
|
|
54
|
+
hint: 'A React application with Module Federation, using Webpack as the bundler.',
|
|
55
|
+
framework: 'react'
|
|
56
|
+
},
|
|
57
|
+
'nx-rspack-mf': {
|
|
58
|
+
label: 'React + Nx + Rspack',
|
|
59
|
+
hint: 'A React application with Module Federation, using Nx as Monorepo manager and Rspack as the bundler.',
|
|
60
|
+
framework: 'react'
|
|
61
|
+
},
|
|
62
|
+
'nx-webpack-mf': {
|
|
63
|
+
label: 'React + Nx + Webpack',
|
|
64
|
+
hint: 'React applications with Module Federation, using Nx as Monorepo manager and Webpack as the bundler.',
|
|
65
|
+
framework: 'react'
|
|
66
|
+
},
|
|
67
|
+
'ng-nx': {
|
|
68
|
+
label: 'Angular app with Nx',
|
|
69
|
+
hint: 'An Angular application with Nx as Monorepo manager.',
|
|
70
|
+
framework: 'angular'
|
|
71
|
+
},
|
|
72
|
+
'qwik-1.5': {
|
|
73
|
+
label: 'Qwik + Vite',
|
|
74
|
+
hint: 'A Qwik v1.5 app using Vite as the bundler.',
|
|
75
|
+
framework: 'qwik'
|
|
76
|
+
},
|
|
77
|
+
'react-rspack-tractor-2.0': {
|
|
78
|
+
label: 'React + Rspack + Tractor 2.0',
|
|
79
|
+
hint: 'A React application using Rspack as the bundler and Tractor 2.0 as the module federation manager.',
|
|
80
|
+
framework: 'react'
|
|
81
|
+
},
|
|
82
|
+
'turbo-rspack-mf': {
|
|
83
|
+
label: 'Turbo + Rspack + Module Federation',
|
|
84
|
+
hint: 'A monorepo using Turborepo, React, and Rspack as the bundler.',
|
|
85
|
+
framework: 'react'
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
async function main() {
|
|
89
|
+
console.clear();
|
|
90
|
+
await (0, __WEBPACK_EXTERNAL_MODULE_node_timers_promises_aedbf14c__.setTimeout)(1000);
|
|
91
|
+
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.updateSettings)({
|
|
92
|
+
aliases: {
|
|
93
|
+
w: 'up',
|
|
94
|
+
s: 'down',
|
|
95
|
+
a: 'left',
|
|
96
|
+
d: 'right'
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.note)('npx create-zephyr-apps@latest');
|
|
100
|
+
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.intro)(`${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgCyan(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(' Create federated applications with Zephyr '))}`);
|
|
101
|
+
const project = await (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.group)({
|
|
102
|
+
path: ({ results })=>(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.text)({
|
|
103
|
+
message: 'Where should we create your project?',
|
|
104
|
+
placeholder: './sparkling-solid',
|
|
105
|
+
validate: (value)=>{
|
|
106
|
+
if (!value) return 'Please enter a path.';
|
|
107
|
+
if ('.' !== value[0]) return 'Please enter a relative path.';
|
|
108
|
+
}
|
|
109
|
+
}),
|
|
110
|
+
type: ()=>(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select)({
|
|
111
|
+
message: 'What type of project you are creating?',
|
|
112
|
+
initialValue: 'web',
|
|
113
|
+
options: [
|
|
114
|
+
{
|
|
115
|
+
value: 'web',
|
|
116
|
+
label: 'Web'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
value: 'react-native',
|
|
120
|
+
label: 'React Native',
|
|
121
|
+
hint: 'You will be building React Native powered by Re.Pack.'
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}),
|
|
125
|
+
templates: ({ results })=>{
|
|
126
|
+
if ('web' === results.type) return (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.select)({
|
|
127
|
+
message: 'Pick a template: ',
|
|
128
|
+
initialValue: 'react-rspack-mf',
|
|
129
|
+
maxItems: 5,
|
|
130
|
+
options: Object.keys(TEMPLATES).map((template)=>({
|
|
131
|
+
value: template,
|
|
132
|
+
label: __WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan(TEMPLATES[template].label),
|
|
133
|
+
hint: TEMPLATES[template].hint
|
|
134
|
+
}))
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
onCancel: ()=>{
|
|
139
|
+
(0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.cancel)('Operation cancelled.');
|
|
140
|
+
process.exit(0);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const temp_dir = __WEBPACK_EXTERNAL_MODULE_tempy__.temporaryDirectory();
|
|
144
|
+
const command_web = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-examples.git -b main ${temp_dir}`;
|
|
145
|
+
const command_react_native = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-repack-example.git -b main ${temp_dir}`;
|
|
146
|
+
const project_path = project.path.replace('./', '').trim();
|
|
147
|
+
const s = (0, __WEBPACK_EXTERNAL_MODULE__clack_prompts_3cae1695__.spinner)();
|
|
148
|
+
if ('web' === project.type) {
|
|
149
|
+
s.start(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan('Cloning subfolder ' + __WEBPACK_EXTERNAL_MODULE_chalk__["default"].green(project.templates) + ' from repository https://github.com/ZephyrCloudIO/zephyr-examples.git'));
|
|
150
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.exec)(command_web, async (err, stdout, stderr)=>{
|
|
151
|
+
if (err) {
|
|
152
|
+
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgRed(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(`Error cloning ${command_web} to ${project_path}...`)));
|
|
153
|
+
console.error(err);
|
|
154
|
+
process.exit(0);
|
|
155
|
+
}
|
|
156
|
+
if (!err) {
|
|
157
|
+
const outputPath = __WEBPACK_EXTERNAL_MODULE_path__["default"].join(process.cwd(), project.path);
|
|
158
|
+
const clonedPath = __WEBPACK_EXTERNAL_MODULE_path__["default"].join(temp_dir, 'examples', project.templates);
|
|
159
|
+
try {
|
|
160
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.cp(clonedPath, outputPath, {
|
|
161
|
+
recursive: true,
|
|
162
|
+
force: true
|
|
163
|
+
});
|
|
164
|
+
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].green(`Project successfully created at ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(project_path)}`));
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgRed(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(`Error cloning to ${project_path}...`)));
|
|
167
|
+
console.error(error);
|
|
168
|
+
process.exit(2);
|
|
169
|
+
} finally{
|
|
170
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.rm(temp_dir, {
|
|
171
|
+
recursive: true,
|
|
172
|
+
force: true
|
|
173
|
+
});
|
|
174
|
+
end_note({
|
|
175
|
+
project
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if ('react-native' === project.type) {
|
|
182
|
+
s.start(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].cyan("Cloning repository https://github.com/ZephyrCloudIO/zephyr-repack-example.git"));
|
|
183
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_child_process_27f17141__.exec)(command_react_native, async (err, stdout, stderr)=>{
|
|
184
|
+
if (err) {
|
|
185
|
+
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgRed(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(`Error cloning to ${project_path}...`)));
|
|
186
|
+
console.error(err);
|
|
187
|
+
process.exit(2);
|
|
188
|
+
}
|
|
189
|
+
if (!err) {
|
|
190
|
+
const outputPath = __WEBPACK_EXTERNAL_MODULE_path__["default"].join(process.cwd(), project.path);
|
|
191
|
+
try {
|
|
192
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.cp(temp_dir, outputPath, {
|
|
193
|
+
recursive: true,
|
|
194
|
+
force: true
|
|
195
|
+
});
|
|
196
|
+
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].green(`Project successfully created at ${__WEBPACK_EXTERNAL_MODULE_chalk__["default"].underline(project_path)}`));
|
|
197
|
+
} catch (error) {
|
|
198
|
+
s.stop(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].bgRed(__WEBPACK_EXTERNAL_MODULE_chalk__["default"].black(`Error clonin to ${project_path}`)));
|
|
199
|
+
console.error(error);
|
|
200
|
+
process.exit(2);
|
|
201
|
+
} finally{
|
|
202
|
+
await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.promises.rm(temp_dir, {
|
|
203
|
+
recursive: true,
|
|
204
|
+
force: true
|
|
205
|
+
});
|
|
206
|
+
end_note({
|
|
207
|
+
project
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
declare const REPO_OWNER = "ZephyrCloudIO";
|
|
2
|
+
declare const REPO_NAME = "zephyr-examples";
|
|
3
|
+
declare const REPACK_REPO = "zephyr-repack-example";
|
|
4
|
+
declare const BASE_REPO = "ZephyrCloudIO/zephyr-examples";
|
|
5
|
+
declare const REPACK_REPO_PATH = "ZephyrCloudIO/zephyr-repack-example";
|
|
6
|
+
declare const TEMPLATES: {
|
|
7
|
+
'rspack-project': {
|
|
8
|
+
label: string;
|
|
9
|
+
hint: string;
|
|
10
|
+
framework: string;
|
|
11
|
+
};
|
|
12
|
+
'react-vite-ts': {
|
|
13
|
+
label: string;
|
|
14
|
+
hint: string;
|
|
15
|
+
framework: string;
|
|
16
|
+
};
|
|
17
|
+
'react-vite-mf': {
|
|
18
|
+
label: string;
|
|
19
|
+
hint: string;
|
|
20
|
+
framework: string;
|
|
21
|
+
};
|
|
22
|
+
'angular-vite': {
|
|
23
|
+
label: string;
|
|
24
|
+
hint: string;
|
|
25
|
+
framework: string;
|
|
26
|
+
};
|
|
27
|
+
'react-webpack-mf': {
|
|
28
|
+
label: string;
|
|
29
|
+
hint: string;
|
|
30
|
+
framework: string;
|
|
31
|
+
};
|
|
32
|
+
'nx-rspack-mf': {
|
|
33
|
+
label: string;
|
|
34
|
+
hint: string;
|
|
35
|
+
framework: string;
|
|
36
|
+
};
|
|
37
|
+
'nx-webpack-mf': {
|
|
38
|
+
label: string;
|
|
39
|
+
hint: string;
|
|
40
|
+
framework: string;
|
|
41
|
+
};
|
|
42
|
+
'ng-nx': {
|
|
43
|
+
label: string;
|
|
44
|
+
hint: string;
|
|
45
|
+
framework: string;
|
|
46
|
+
};
|
|
47
|
+
'qwik-1.5': {
|
|
48
|
+
label: string;
|
|
49
|
+
hint: string;
|
|
50
|
+
framework: string;
|
|
51
|
+
};
|
|
52
|
+
'react-rspack-tractor-2.0': {
|
|
53
|
+
label: string;
|
|
54
|
+
hint: string;
|
|
55
|
+
framework: string;
|
|
56
|
+
};
|
|
57
|
+
'turbo-rspack-mf': {
|
|
58
|
+
label: string;
|
|
59
|
+
hint: string;
|
|
60
|
+
framework: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export { REPO_OWNER, REPO_NAME, REPACK_REPO, BASE_REPO, REPACK_REPO_PATH, TEMPLATES };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface GithubTreeItem {
|
|
2
|
+
path: string;
|
|
3
|
+
type: 'tree' | 'blob';
|
|
4
|
+
}
|
|
5
|
+
export interface ExampleMetadata {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}
|
|
10
|
+
export interface WebCreationOptions {
|
|
11
|
+
path: string;
|
|
12
|
+
template: string;
|
|
13
|
+
framework: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ReactNativeCreationOptions {
|
|
16
|
+
path: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CLIOptions {
|
|
19
|
+
path: string;
|
|
20
|
+
type: 'web' | 'react-native';
|
|
21
|
+
/** At the moment, if users opt for web they will only be asked for a template without host name and remote_name */
|
|
22
|
+
templates: string | undefined;
|
|
23
|
+
install: boolean;
|
|
24
|
+
}
|
package/package/index.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
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
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: 'react-native',
|
|
71
|
+
label: 'React Native',
|
|
72
|
+
hint: 'You will be building React Native powered by Re.Pack.',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
}),
|
|
76
|
+
|
|
77
|
+
templates: ({ results }) => {
|
|
78
|
+
|
|
79
|
+
if (results.type === 'web') {
|
|
80
|
+
return select({
|
|
81
|
+
message: 'Pick a template: ',
|
|
82
|
+
initialValue: 'react-rspack-mf',
|
|
83
|
+
maxItems: 5,
|
|
84
|
+
options: Object.keys(TEMPLATES).map((template) => {
|
|
85
|
+
return {
|
|
86
|
+
value: template as keyof typeof TEMPLATES,
|
|
87
|
+
label: c.cyan(TEMPLATES[template as keyof typeof TEMPLATES].label),
|
|
88
|
+
hint: TEMPLATES[template as keyof typeof TEMPLATES].hint
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
onCancel: () => {
|
|
98
|
+
cancel('Operation cancelled.');
|
|
99
|
+
process.exit(0);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
) as CLIOptions;
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
const temp_dir = tempy.temporaryDirectory()
|
|
107
|
+
|
|
108
|
+
const command_web = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-examples.git -b main ${temp_dir}`
|
|
109
|
+
const command_react_native = `git clone --depth 1 https://github.com/ZephyrCloudIO/zephyr-repack-example.git -b main ${temp_dir}`
|
|
110
|
+
|
|
111
|
+
const project_path = project.path.replace('./', '').trim()
|
|
112
|
+
|
|
113
|
+
const s = spinner()
|
|
114
|
+
if (project.type === 'web') {
|
|
115
|
+
|
|
116
|
+
s.start(c.cyan('Cloning subfolder ' + c.green(project.templates) + ' from repository https://github.com/ZephyrCloudIO/zephyr-examples.git'))
|
|
117
|
+
|
|
118
|
+
exec(command_web, async (err, stdout, stderr) => {
|
|
119
|
+
|
|
120
|
+
if (err) {
|
|
121
|
+
s.stop(c.bgRed(c.black(`Error cloning ${command_web} to ${project_path}...`)))
|
|
122
|
+
console.error(err);
|
|
123
|
+
process.exit(0);
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!err) {
|
|
128
|
+
const outputPath = path.join(process.cwd(), project.path);
|
|
129
|
+
|
|
130
|
+
const clonedPath = path.join(temp_dir, 'examples', project.templates as string)
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
const result2 = await fs.promises.cp(clonedPath, outputPath, {
|
|
134
|
+
recursive: true,
|
|
135
|
+
force: true
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
s.stop(c.green(`Project successfully created at ${c.underline(project_path)}`))
|
|
139
|
+
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error(c.bgRed(c.black(`Error cloning to ${project_path}...`)))
|
|
142
|
+
console.error(error)
|
|
143
|
+
process.exit(2)
|
|
144
|
+
} finally {
|
|
145
|
+
await fs.promises.rm(temp_dir, { recursive: true, force: true })
|
|
146
|
+
end_note({ project })
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
if (project.type === 'react-native') {
|
|
155
|
+
|
|
156
|
+
s.start(c.cyan(`Cloning repository https://github.com/ZephyrCloudIO/zephyr-repack-example.git`))
|
|
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
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
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 };
|
|
@@ -0,0 +1,37 @@
|
|
|
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(`${project.path} && git config user.name`, (err, stdout, stderr) => {
|
|
9
|
+
console.log(stdout);
|
|
10
|
+
|
|
11
|
+
const user_name = stdout.toString().trim();
|
|
12
|
+
|
|
13
|
+
const repo_name = project.path.split('/').pop();
|
|
14
|
+
|
|
15
|
+
let next_steps;
|
|
16
|
+
|
|
17
|
+
if (project.type === 'web') {
|
|
18
|
+
next_steps = `cd ${repo_name} \npnpm install\ngit remote add origin https://github.com/${user_name ?? 'YourUsername'}/${repo_name}.git\npnpm run build`;
|
|
19
|
+
} else {
|
|
20
|
+
next_steps = `cd ${repo_name} \npnpm install\nrm -rf .git\ngit remote set origin https://github.com/${user_name.length >= 1 ? user_name : 'YourUsername'}/${repo_name}.git\npnpm run build`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
note(next_steps, 'Next steps.');
|
|
24
|
+
});
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(error);
|
|
27
|
+
} finally {
|
|
28
|
+
const end_notes = [
|
|
29
|
+
`Discord: ${c.underline(c.cyan('https://zephyr-cloud.io/discord'))}`,
|
|
30
|
+
`Documentation: ${c.underline(c.cyan('https://zephyr-cloud.io/docs'))}`,
|
|
31
|
+
`Open an issue: ${c.underline(c.cyan('https://github.com/ZephyrCloudIO/create-zephyr-apps/issues'))}`,
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
note(Object.values(end_notes).join('\n'), 'Problems?');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
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/package.json
CHANGED
|
@@ -1,12 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-zephyr-apps",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"module": "./src/index.ts",
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
+
"build": "rslib build",
|
|
8
|
+
"dev": "tsx package/index.ts"
|
|
7
9
|
},
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "ZephyrCloudIO",
|
|
12
|
+
"url": "https://github.com/ZephyrCloudIO"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"create-zephyr-apps": "./dist/index.mjs"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@clack/core": "^0.4.1",
|
|
19
|
+
"@clack/prompts": "^0.9.1",
|
|
20
|
+
"chalk": "^5.4.1",
|
|
21
|
+
"picocolors": "^1.1.1",
|
|
22
|
+
"tempy": "^3.1.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@rslib/core": "^0.3.2",
|
|
26
|
+
"@types/degit": "^2.8.6",
|
|
27
|
+
"@types/node": "^22.10.7",
|
|
28
|
+
"ts-node": "^10.9.2",
|
|
29
|
+
"tsx": "^4.19.2",
|
|
30
|
+
"typescript": "^5.7.3"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"typescript": "^5.0.0"
|
|
34
|
+
},
|
|
35
|
+
"packageManager": "pnpm@9.15.0",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"zephyr",
|
|
41
|
+
"create-zephyr-apps",
|
|
42
|
+
"zephyr-apps",
|
|
43
|
+
"zephyr-cli",
|
|
44
|
+
"zephyr-example",
|
|
45
|
+
"zephyr-template",
|
|
46
|
+
"example",
|
|
47
|
+
"template"
|
|
48
|
+
]
|
|
12
49
|
}
|
|
50
|
+
|
package/rslib.config.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|