create-blocklet 0.3.2 → 0.3.5
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/index.js +33 -26
- package/lib/did.js +1 -1
- package/lib/git.js +31 -8
- package/lib/index.js +8 -4
- package/lib/npm.js +10 -3
- package/lib/server.js +22 -2
- package/package.json +7 -8
- package/{template-static/blocklet-page → templates/blocklet-page-static}/README.md +0 -0
- package/{template-static/blocklet-page → templates/blocklet-page-static}/blocklet.md +0 -0
- package/{template-static/blocklet-page → templates/blocklet-page-static}/blocklet.yml +0 -0
- package/{template-static/blocklet-page → templates/blocklet-page-static}/package.json +1 -1
- package/{template-static/blocklet-page → templates/blocklet-page-static}/site/blocks/CustomBlock.mdx +0 -0
- package/{template-static/blocklet-page → templates/blocklet-page-static}/site/composes/MyLayout.mdx +0 -0
- package/{template-static/blocklet-page → templates/blocklet-page-static}/site/pages/index.mdx +0 -0
- package/{template-static/blocklet-page → templates/blocklet-page-static}/xmark.yml +0 -0
- package/{template-api/express → templates/express-api}/README.md +0 -0
- package/{template-api/express → templates/express-api}/api/hooks/pre-start.js +0 -0
- package/{template-api/express → templates/express-api}/api/index.js +0 -0
- package/{template-api/express → templates/express-api}/api/libs/auth.js +0 -0
- package/{template-api/express → templates/express-api}/api/libs/env.js +0 -0
- package/{template-api/express → templates/express-api}/api/libs/logger.js +0 -0
- package/{template-api/express → templates/express-api}/blocklet.md +0 -0
- package/{template-api/express → templates/express-api}/blocklet.yml +3 -4
- package/{template-api/express → templates/express-api}/package.json +0 -0
- package/{template-api/express → templates/express-api}/screenshots/.gitkeep +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/.eslintrc.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/README.md +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/api/hooks/pre-start.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/api/index.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/api/libs/auth.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/api/libs/env.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/api/libs/logger.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/api/routes/index.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/blocklet.md +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/blocklet.yml +3 -4
- package/{template-dapp/nextjs → templates/nextjs-dapp}/next.config.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/package.json +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/pages/_app.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/pages/api/hello.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/pages/index.js +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/styles/Home.module.css +0 -0
- package/{template-dapp/nextjs → templates/nextjs-dapp}/styles/globals.css +0 -0
- package/{template-dapp/react → templates/react-dapp}/.env +0 -0
- package/{template-dapp/react → templates/react-dapp}/.env.local +0 -0
- package/{template-dapp/react → templates/react-dapp}/README.md +0 -0
- package/{template-dapp/react → templates/react-dapp}/api/hooks/pre-start.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/api/index.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/api/libs/auth.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/api/libs/env.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/api/libs/logger.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/api/routes/index.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/blocklet.md +0 -0
- package/{template-dapp/react → templates/react-dapp}/blocklet.yml +3 -4
- package/templates/react-dapp/craco.config.js +17 -0
- package/{template-dapp/react → templates/react-dapp}/package.json +3 -3
- package/{template-dapp/react → templates/react-dapp}/public/index.html +0 -0
- package/{template-dapp/react → templates/react-dapp}/src/app.css +0 -0
- package/{template-dapp/react → templates/react-dapp}/src/app.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/src/index.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/src/libs/api.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/src/logo.svg +0 -0
- package/{template-dapp/react → templates/react-dapp}/src/pages/about.js +0 -0
- package/{template-dapp/react → templates/react-dapp}/src/pages/home.js +0 -0
- package/{template-static/react → templates/react-static}/.env +0 -0
- package/{template-static/react → templates/react-static}/README.md +0 -0
- package/{template-static/react → templates/react-static}/blocklet.md +0 -0
- package/{template-static/react → templates/react-static}/blocklet.yml +3 -4
- package/templates/react-static/craco.config.js +11 -0
- package/{template-static/react → templates/react-static}/package.json +3 -2
- package/{template-static/react → templates/react-static}/public/index.html +0 -0
- package/{template-static/react → templates/react-static}/src/app.css +0 -0
- package/{template-static/react → templates/react-static}/src/app.js +0 -0
- package/{template-static/react → templates/react-static}/src/index.js +0 -0
- package/{template-static/react → templates/react-static}/src/logo.svg +0 -0
- package/{template-static/react → templates/react-static}/src/pages/about.js +0 -0
- package/{template-static/react → templates/react-static}/src/pages/home.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/.browserslistrc +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/.env +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/.eslintrc.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/README.md +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/api/hooks/pre-start.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/api/index.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/api/libs/auth.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/api/libs/env.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/api/libs/logger.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/api/routes/index.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/blocklet.md +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/blocklet.yml +3 -4
- package/{template-dapp/vue → templates/vue-dapp}/index.html +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/package.json +1 -1
- package/{template-dapp/vue → templates/vue-dapp}/src/App.vue +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/src/assets/logo.png +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/src/components/HelloWorld.vue +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/src/libs/api.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/src/main.js +0 -0
- package/{template-dapp/vue → templates/vue-dapp}/vite.config.js +0 -0
- package/{template-dapp/vue2 → templates/vue-static}/.browserslistrc +0 -0
- package/{template-dapp/vue2 → templates/vue-static}/.env +0 -0
- package/{template-static/vue → templates/vue-static}/.eslintrc.js +0 -0
- package/{template-static/vue → templates/vue-static}/README.md +0 -0
- package/{template-static/vue → templates/vue-static}/blocklet.md +0 -0
- package/{template-static/vue → templates/vue-static}/blocklet.yml +3 -4
- package/{template-static/vue → templates/vue-static}/index.html +0 -0
- package/{template-static/vue → templates/vue-static}/package.json +1 -1
- package/{template-static/vue → templates/vue-static}/src/App.vue +0 -0
- package/{template-dapp/vue2 → templates/vue-static}/src/assets/logo.png +0 -0
- package/{template-static/vue → templates/vue-static}/src/components/HelloWorld.vue +0 -0
- package/{template-static/vue → templates/vue-static}/src/main.js +0 -0
- package/{template-static/vue → templates/vue-static}/vite.config.js +0 -0
- package/{template-static/vue → templates/vue2-dapp}/.browserslistrc +0 -0
- package/{template-static/vue → templates/vue2-dapp}/.env +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/.eslintrc.js +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/README.md +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/api/hooks/pre-start.js +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/api/index.js +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/api/libs/auth.js +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/api/libs/env.js +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/api/libs/logger.js +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/api/routes/index.js +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/babel.config.js +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/blocklet.md +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/blocklet.yml +4 -4
- package/{template-dapp/vue2 → templates/vue2-dapp}/jsconfig.json +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/package.json +1 -1
- package/{template-dapp/vue2 → templates/vue2-dapp}/public/index.html +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/src/App.vue +0 -0
- package/{template-static/vue → templates/vue2-dapp}/src/assets/logo.png +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/src/components/HelloWorld.vue +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/src/libs/api.js +0 -0
- package/{template-dapp/vue2 → templates/vue2-dapp}/src/main.js +0 -0
- package/templates/vue2-dapp/vue.config.js +18 -0
- package/{template-static/vue2 → templates/vue2-static}/.browserslistrc +0 -0
- package/{template-static/vue2 → templates/vue2-static}/.env +0 -0
- package/{template-static/vue2 → templates/vue2-static}/.eslintrc.js +0 -0
- package/{template-static/vue2 → templates/vue2-static}/README.md +0 -0
- package/{template-static/vue2 → templates/vue2-static}/babel.config.js +0 -0
- package/{template-static/vue2 → templates/vue2-static}/blocklet.md +0 -0
- package/{template-static/vue2 → templates/vue2-static}/blocklet.yml +3 -4
- package/{template-static/vue2 → templates/vue2-static}/jsconfig.json +0 -0
- package/{template-static/vue2 → templates/vue2-static}/package.json +0 -0
- package/{template-static/vue2 → templates/vue2-static}/public/index.html +0 -0
- package/{template-static/vue2 → templates/vue2-static}/src/App.vue +0 -0
- package/{template-static/vue2 → templates/vue2-static}/src/assets/logo.png +0 -0
- package/{template-static/vue2 → templates/vue2-static}/src/components/HelloWorld.vue +0 -0
- package/{template-static/vue2 → templates/vue2-static}/src/main.js +0 -0
- package/templates/vue2-static/vue.config.js +13 -0
- package/template-dapp/react/src/setupProxy.js +0 -12
- package/template-dapp/vue2/vue.config.js +0 -10
- package/template-static/vue2/vue.config.js +0 -3
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import boxen from 'boxen';
|
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
import { execSync } from 'child_process';
|
|
7
7
|
import { cd, argv, fs, YAML, chalk, path } from 'zx';
|
|
8
|
-
import
|
|
8
|
+
import ora from 'ora';
|
|
9
9
|
import prompts from 'prompts';
|
|
10
10
|
import * as envfile from 'envfile';
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ import { checkServerInstalled, checkServerRunning, checkSatisfiedVersion, getSer
|
|
|
15
15
|
import { toBlockletDid } from './lib/did.js';
|
|
16
16
|
import { initGitRepo } from './lib/git.js';
|
|
17
17
|
|
|
18
|
-
const { yellow, red, green, cyan, blue, bold
|
|
18
|
+
const { yellow, red, green, cyan, blue, bold } = chalk;
|
|
19
19
|
|
|
20
20
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
21
21
|
|
|
@@ -182,12 +182,14 @@ async function init() {
|
|
|
182
182
|
name: 'authorName',
|
|
183
183
|
message: 'Author name:',
|
|
184
184
|
initial: authorInfo?.name || '',
|
|
185
|
+
validate: (name) => (name ? true : 'Author name is required'),
|
|
185
186
|
},
|
|
186
187
|
{
|
|
187
188
|
type: 'text',
|
|
188
189
|
name: 'authorEmail',
|
|
189
190
|
message: 'Author email:',
|
|
190
191
|
initial: authorInfo?.email || '',
|
|
192
|
+
validate: (email) => (email ? true : 'Author email is required'),
|
|
191
193
|
},
|
|
192
194
|
],
|
|
193
195
|
{
|
|
@@ -204,7 +206,7 @@ async function init() {
|
|
|
204
206
|
// user choice associated with prompts
|
|
205
207
|
const { type, framework, overwrite, packageName, authorName, authorEmail } = result;
|
|
206
208
|
|
|
207
|
-
|
|
209
|
+
await echoDocument();
|
|
208
210
|
|
|
209
211
|
const root = path.join(cwd, targetDir);
|
|
210
212
|
|
|
@@ -214,17 +216,20 @@ async function init() {
|
|
|
214
216
|
fs.mkdirSync(root);
|
|
215
217
|
}
|
|
216
218
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
219
|
+
const checkSpinner = ora({
|
|
220
|
+
text: 'Checking blocklet server runtime environment\n',
|
|
221
|
+
}).start();
|
|
220
222
|
|
|
221
223
|
const isServerInstalled = await checkServerInstalled();
|
|
222
224
|
const isSatisfiedVersion = await checkSatisfiedVersion();
|
|
223
225
|
const isServerRunning = await checkServerRunning();
|
|
226
|
+
checkSpinner.succeed('Done');
|
|
227
|
+
|
|
228
|
+
console.log(`\nScaffolding project in ${cyan(root)}`);
|
|
224
229
|
|
|
225
|
-
|
|
230
|
+
const scaffoldSpinner = ora('Creating project...').start();
|
|
226
231
|
|
|
227
|
-
const templateDir = path.join(__dirname, `
|
|
232
|
+
const templateDir = path.join(__dirname, `templates/${framework}-${type}`);
|
|
228
233
|
const name = packageName || targetDir;
|
|
229
234
|
|
|
230
235
|
// copy common files
|
|
@@ -305,9 +310,9 @@ async function init() {
|
|
|
305
310
|
// fs.writeFileSync(path.join(root, 'logo.png'), pngIcon);
|
|
306
311
|
})();
|
|
307
312
|
|
|
313
|
+
scaffoldSpinner.succeed('✨ Done. Now run:\n');
|
|
314
|
+
|
|
308
315
|
const related = path.relative(cwd, root);
|
|
309
|
-
console.log('\n\n✨ Done. Now run:\n');
|
|
310
|
-
stopSpinner();
|
|
311
316
|
|
|
312
317
|
// const pkgManager =
|
|
313
318
|
// // eslint-disable-next-line no-nested-ternary
|
|
@@ -317,19 +322,20 @@ async function init() {
|
|
|
317
322
|
// ? 'yarn'
|
|
318
323
|
// : 'npm';
|
|
319
324
|
try {
|
|
320
|
-
const { yes } = await prompts(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
);
|
|
325
|
+
// const { yes } = await prompts(
|
|
326
|
+
// {
|
|
327
|
+
// type: 'confirm',
|
|
328
|
+
// name: 'yes',
|
|
329
|
+
// initial: 'Y',
|
|
330
|
+
// message: 'Install and start it now?',
|
|
331
|
+
// },
|
|
332
|
+
// {
|
|
333
|
+
// onCancel: () => {
|
|
334
|
+
// throw new Error(`${red('✖')} Operation cancelled`);
|
|
335
|
+
// },
|
|
336
|
+
// }
|
|
337
|
+
// );
|
|
338
|
+
const yes = false;
|
|
333
339
|
let hasStart = false;
|
|
334
340
|
|
|
335
341
|
await initGitRepo(root);
|
|
@@ -411,7 +417,7 @@ async function init() {
|
|
|
411
417
|
}
|
|
412
418
|
|
|
413
419
|
if (!hasStart) {
|
|
414
|
-
console.log(dim('\n start it later by:\n'));
|
|
420
|
+
// console.log(dim('\n start it later by:\n'));
|
|
415
421
|
if (root !== cwd) console.log(blue(` cd ${bold(related)}`));
|
|
416
422
|
|
|
417
423
|
console.log(blue(` ${defaultAgent === 'yarn' ? 'yarn' : `${defaultAgent} install`}`));
|
|
@@ -463,9 +469,10 @@ async function init() {
|
|
|
463
469
|
const env = envfile.parse(envContent);
|
|
464
470
|
modifyFn(env);
|
|
465
471
|
write('.env', envfile.stringify(env));
|
|
466
|
-
} else {
|
|
467
|
-
console.warn(`\n${yellow('No .env file found, please add one.')}`);
|
|
468
472
|
}
|
|
473
|
+
// else {
|
|
474
|
+
// console.warn(`\n${yellow('No .env file found, please add one.')}`);
|
|
475
|
+
// }
|
|
469
476
|
}
|
|
470
477
|
}
|
|
471
478
|
|
package/lib/did.js
CHANGED
|
@@ -7,7 +7,7 @@ import { fromPublicKey } from '@arcblock/did';
|
|
|
7
7
|
const { types } = Mcrypto;
|
|
8
8
|
|
|
9
9
|
export function toBlockletDid(name) {
|
|
10
|
-
const pk = toHex(name);
|
|
10
|
+
const pk = toHex(Buffer.from(typeof name === 'string' ? name.trim() : name));
|
|
11
11
|
return fromPublicKey(pk, { role: types.RoleType.ROLE_ANY });
|
|
12
12
|
}
|
|
13
13
|
|
package/lib/git.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { $, which, cd } from 'zx';
|
|
1
|
+
import { $, which, cd, chalk } from 'zx';
|
|
2
|
+
|
|
3
|
+
const { yellow } = chalk;
|
|
2
4
|
|
|
3
5
|
$.verbose = false;
|
|
4
6
|
|
|
7
|
+
async function canInitGit() {
|
|
8
|
+
const isInstalled = await isGitInstalled();
|
|
9
|
+
const gitInfo = await getUserInfo();
|
|
10
|
+
if (isInstalled && gitInfo.name && gitInfo.email) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
export async function isGitInstalled() {
|
|
6
17
|
try {
|
|
7
18
|
await which('git');
|
|
@@ -12,14 +23,26 @@ export async function isGitInstalled() {
|
|
|
12
23
|
}
|
|
13
24
|
|
|
14
25
|
export async function initGitRepo(root) {
|
|
15
|
-
await
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
const canInstalled = await canInitGit();
|
|
27
|
+
if (canInstalled) {
|
|
28
|
+
await cd(root);
|
|
29
|
+
await $`git init`;
|
|
30
|
+
await $`git add .`;
|
|
31
|
+
await $`git commit -m 'init'`;
|
|
32
|
+
} else {
|
|
33
|
+
console.warn(`${yellow('Git is not installed')}`);
|
|
34
|
+
}
|
|
19
35
|
}
|
|
20
36
|
|
|
21
37
|
export async function getUserInfo() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
try {
|
|
39
|
+
const { stdout: name } = await $`git config user.name`;
|
|
40
|
+
const { stdout: email } = await $`git config user.email`;
|
|
41
|
+
return { name: name.trim(), email: email.trim() };
|
|
42
|
+
} catch {
|
|
43
|
+
return {
|
|
44
|
+
name: '',
|
|
45
|
+
email: '',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
25
48
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { $ } from 'zx';
|
|
2
2
|
import { getAuthor } from './npm.js';
|
|
3
3
|
import { getUserInfo } from './git.js';
|
|
4
|
+
import { getUserInfo as getServerUserInfo } from './server.js';
|
|
4
5
|
|
|
5
6
|
$.verbose = false;
|
|
6
7
|
|
|
@@ -10,10 +11,13 @@ export async function getOutput(cmd) {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export async function getUser() {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
function purifyString(str) {
|
|
15
|
+
return [undefined, 'undefined', null, 'null'].includes(str) ? '' : str;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const [npmAuthor, gitUser, serverUser] = await Promise.all([getAuthor(), getUserInfo(), getServerUserInfo()]);
|
|
15
19
|
return {
|
|
16
|
-
name: npmAuthor.name || gitUser.name,
|
|
17
|
-
email: npmAuthor.email || gitUser.email,
|
|
20
|
+
name: purifyString(serverUser.name) || purifyString(npmAuthor.name) || purifyString(gitUser.name) || '',
|
|
21
|
+
email: purifyString(serverUser.email) || purifyString(npmAuthor.email) || purifyString(gitUser.email) || '',
|
|
18
22
|
};
|
|
19
23
|
}
|
package/lib/npm.js
CHANGED
|
@@ -4,8 +4,15 @@ import { $ } from 'zx';
|
|
|
4
4
|
$.verbose = false;
|
|
5
5
|
|
|
6
6
|
export async function getAuthor() {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
try {
|
|
8
|
+
const { stdout: name } = await $`npm config get init.author.name`;
|
|
9
|
+
const { stdout: email } = await $`npm config get init.author.email`;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
return { name: name?.trim(), email: email?.trim() };
|
|
12
|
+
} catch {
|
|
13
|
+
return {
|
|
14
|
+
name: '',
|
|
15
|
+
email: '',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
11
18
|
}
|
package/lib/server.js
CHANGED
|
@@ -13,8 +13,12 @@ export async function checkServerInstalled() {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export async function getServerVersion() {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
try {
|
|
17
|
+
const { stdout: output } = await $`blocklet --version`;
|
|
18
|
+
return output.trim();
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return '0.0.0';
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export async function getServerStatus() {
|
|
@@ -45,3 +49,19 @@ export async function getServerDirectory() {
|
|
|
45
49
|
const directory = matchStr.replace(/Blocklet Server Data Directory:[\s]*([\S]+)\/\.abtnode\n/gm, '$1');
|
|
46
50
|
return directory;
|
|
47
51
|
}
|
|
52
|
+
|
|
53
|
+
export async function getUserInfo() {
|
|
54
|
+
try {
|
|
55
|
+
const { stdout: user } = await $`blocklet config get user`;
|
|
56
|
+
const { stdout: email } = await $`blocklet config get email`;
|
|
57
|
+
return {
|
|
58
|
+
user: user?.trim(),
|
|
59
|
+
email: email?.trim(),
|
|
60
|
+
};
|
|
61
|
+
} catch {
|
|
62
|
+
return {
|
|
63
|
+
user: '',
|
|
64
|
+
email: '',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-blocklet",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"exports": "./index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "git@github.com:blocklet/create-blocklet.git",
|
|
@@ -13,9 +13,7 @@
|
|
|
13
13
|
"index.js",
|
|
14
14
|
"common",
|
|
15
15
|
"lib",
|
|
16
|
-
"
|
|
17
|
-
"template-dapp",
|
|
18
|
-
"template-static"
|
|
16
|
+
"templates"
|
|
19
17
|
],
|
|
20
18
|
"engines": {
|
|
21
19
|
"node": ">=16.0.0"
|
|
@@ -31,19 +29,20 @@
|
|
|
31
29
|
"test:run": "vitest run"
|
|
32
30
|
},
|
|
33
31
|
"dependencies": {
|
|
34
|
-
"@arcblock/did": "^1.
|
|
35
|
-
"@ocap/mcrypto": "^1.
|
|
36
|
-
"@ocap/util": "^1.
|
|
32
|
+
"@arcblock/did": "^1.15.7",
|
|
33
|
+
"@ocap/mcrypto": "^1.15.7",
|
|
34
|
+
"@ocap/util": "^1.15.7",
|
|
37
35
|
"boxen": "^6.2.1",
|
|
38
36
|
"ejs": "^3.1.6",
|
|
39
37
|
"envfile": "^6.17.0",
|
|
40
38
|
"figlet": "^1.5.2",
|
|
41
39
|
"gradient-string": "^2.0.0",
|
|
42
40
|
"jdenticon": "^3.1.1",
|
|
41
|
+
"ora": "^6.1.0",
|
|
43
42
|
"prompts": "^2.4.2",
|
|
44
43
|
"semver": "^7.3.5",
|
|
45
44
|
"terminal-link": "^3.0.0",
|
|
46
|
-
"zx": "^6.0.
|
|
45
|
+
"zx": "^6.0.7"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@arcblock/eslint-config": "0.1.8",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/{template-static/blocklet-page → templates/blocklet-page-static}/site/blocks/CustomBlock.mdx
RENAMED
|
File without changes
|
package/{template-static/blocklet-page → templates/blocklet-page-static}/site/composes/MyLayout.mdx
RENAMED
|
File without changes
|
package/{template-static/blocklet-page → templates/blocklet-page-static}/site/pages/index.mdx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const port = process.env.BLOCKLET_PORT || process.env.PORT || 8080;
|
|
2
|
+
const dappPort = process.env.APP_PORT || 3030;
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
devServer: {
|
|
6
|
+
port,
|
|
7
|
+
client: {
|
|
8
|
+
// If you want to development this blocklet without blocklet-server, you can delete next line, otherwise the hot reload will be failed.
|
|
9
|
+
webSocketURL: 'wss://0.0.0.0/ws',
|
|
10
|
+
},
|
|
11
|
+
proxy: {
|
|
12
|
+
'/api': {
|
|
13
|
+
target: `http://127.0.0.1:${dappPort}`,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"name": "template-react",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"dev": "
|
|
6
|
-
"build": "
|
|
5
|
+
"dev": "craco start",
|
|
6
|
+
"build": "craco build",
|
|
7
7
|
"eject": "react-scripts eject",
|
|
8
8
|
"lint": "eslint src api --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
9
9
|
"start": "npm-run-all --parallel start:*",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@arcblock/did-auth": "^1.15.2",
|
|
43
43
|
"@arcblock/did-auth-storage-nedb": "^1.6.3",
|
|
44
44
|
"@blocklet/sdk": "^1.7.0",
|
|
45
|
+
"@craco/craco": "^6.4.3",
|
|
45
46
|
"@ocap/client": "^1.15.2",
|
|
46
47
|
"@ocap/mcrypto": "^1.15.2",
|
|
47
48
|
"@ocap/wallet": "^1.15.2",
|
|
@@ -70,7 +71,6 @@
|
|
|
70
71
|
"eslint-plugin-react": "^7.24.0",
|
|
71
72
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
72
73
|
"eslint-plugin-unicorn": "^34.0.1",
|
|
73
|
-
"http-proxy-middleware": "^2.0.4",
|
|
74
74
|
"husky": "^7.0.4",
|
|
75
75
|
"lint-staged": "^12.3.7",
|
|
76
76
|
"nodemon": "^2.0.15",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const port = process.env.BLOCKLET_PORT || process.env.PORT || 8080;
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
devServer: {
|
|
5
|
+
port,
|
|
6
|
+
client: {
|
|
7
|
+
// If you want to development this blocklet without blocklet-server, you can delete next line, otherwise the hot reload will be failed.
|
|
8
|
+
webSocketURL: 'wss://0.0.0.0/ws',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"name": "template-react",
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"dev": "
|
|
6
|
-
"build": "
|
|
5
|
+
"dev": "craco start",
|
|
6
|
+
"build": "craco build",
|
|
7
7
|
"eject": "react-scripts eject",
|
|
8
8
|
"lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
9
9
|
"start": "npm run dev",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
]
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@craco/craco": "^6.4.3",
|
|
38
39
|
"react": "^17.0.2",
|
|
39
40
|
"react-dom": "^17.0.2",
|
|
40
41
|
"react-router-dom": "^6.2.2",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"start:api": "NODE_ENV=development nodemon api/index.js -w api",
|
|
11
11
|
"clean": "rm -rf .blocklet",
|
|
12
12
|
"bundle": "npm run bundle:client && npm run bundle:api",
|
|
13
|
-
"bundle:client": "vite build --base /.blocklet/proxy/<%= did
|
|
13
|
+
"bundle:client": "vite build --base /.blocklet/proxy/<%= did %>/",
|
|
14
14
|
"bundle:api": "npm run clean && blocklet bundle --zip --create-release",
|
|
15
15
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
16
16
|
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"lint": "eslint src --ext .mjs,.js,.vue",
|
|
9
9
|
"serve": "vite preview",
|
|
10
10
|
"clean": "rm -rf .blocklet",
|
|
11
|
-
"bundle": "npm run clean && vite build --base /.blocklet/proxy/<%= did
|
|
11
|
+
"bundle": "npm run clean && vite build --base /.blocklet/proxy/<%= did %>/ && blocklet bundle --zip --create-release",
|
|
12
12
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
13
13
|
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
14
14
|
"prepare": "husky install"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -22,6 +22,7 @@ files:
|
|
|
22
22
|
- blocklet.md
|
|
23
23
|
- screenshots
|
|
24
24
|
- api/hooks/pre-start.js
|
|
25
|
+
- dist
|
|
25
26
|
interfaces:
|
|
26
27
|
- type: web
|
|
27
28
|
name: publicUrl
|
|
@@ -33,10 +34,9 @@ community: ''
|
|
|
33
34
|
documentation: ''
|
|
34
35
|
homepage: ''
|
|
35
36
|
license: ''
|
|
36
|
-
|
|
37
|
-
price:
|
|
38
|
-
|
|
39
|
-
shares: []
|
|
37
|
+
payment:
|
|
38
|
+
price: []
|
|
39
|
+
share: []
|
|
40
40
|
timeout:
|
|
41
41
|
start: 60
|
|
42
42
|
requirements:
|
|
File without changes
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"start:api": "NODE_ENV=development nodemon api/index.js -w api",
|
|
12
12
|
"clean": "rm -rf .blocklet",
|
|
13
13
|
"bundle": "npm run bundle:client && npm run bundle:api",
|
|
14
|
-
"bundle:client": "PUBLIC_PATH=/.blocklet/proxy
|
|
14
|
+
"bundle:client": "PUBLIC_PATH=/.blocklet/proxy/<%= did %> npm run build",
|
|
15
15
|
"bundle:api": "npm run clean && blocklet bundle --zip --create-release",
|
|
16
16
|
"deploy": "npm run bundle && blocklet deploy .blocklet/bundle",
|
|
17
17
|
"upload": "npm run bundle && blocklet upload .blocklet/release/blocklet.json",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const port = process.env.BLOCKLET_PORT || process.env.PORT || 8080;
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
publicPath: process.env.PUBLIC_PATH || '/',
|
|
5
|
+
devServer: {
|
|
6
|
+
port,
|
|
7
|
+
allowedHosts: 'all',
|
|
8
|
+
client: {
|
|
9
|
+
// If you want to development this blocklet without blocklet-server, you can delete next line, otherwise the hot reload will be failed.
|
|
10
|
+
webSocketURL: 'wss://0.0.0.0/ws',
|
|
11
|
+
},
|
|
12
|
+
proxy: {
|
|
13
|
+
'/api': {
|
|
14
|
+
target: 'http://127.0.0.1:3030',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const port = process.env.BLOCKLET_PORT || process.env.PORT || 8080;
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
publicPath: process.env.PUBLIC_PATH || '/',
|
|
5
|
+
devServer: {
|
|
6
|
+
port,
|
|
7
|
+
allowedHosts: 'all',
|
|
8
|
+
client: {
|
|
9
|
+
// If you want to development this blocklet without blocklet-server, you can delete next line, otherwise the hot reload will be failed.
|
|
10
|
+
webSocketURL: 'wss://0.0.0.0/ws',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
require('dotenv-flow').config();
|
|
2
|
-
|
|
3
|
-
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
4
|
-
|
|
5
|
-
module.exports = (app) => {
|
|
6
|
-
app.use(
|
|
7
|
-
'/api',
|
|
8
|
-
createProxyMiddleware({
|
|
9
|
-
target: `http://127.0.0.1:${process.env.APP_PORT || 3030}`,
|
|
10
|
-
})
|
|
11
|
-
);
|
|
12
|
-
};
|