@blocklet/cli 1.16.43-beta-20250422-042711-c40bec75 → 1.16.43-beta-20250425-130658-8da18f4d

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.
@@ -5,7 +5,6 @@ const fs = require('fs');
5
5
  const path = require('path');
6
6
  const expandTilde = require('expand-tilde');
7
7
  const tar = require('tar');
8
- const FormData = require('form-data');
9
8
  const chalk = require('chalk');
10
9
  const slugify = require('slugify');
11
10
  const { joinURL } = require('ufo');
@@ -21,8 +20,9 @@ const { hasMountPoint } = require('@blocklet/meta/lib/engine');
21
20
  const { BLOCKLET_BUNDLE_FOLDER } = require('@blocklet/constant');
22
21
  const hasReservedKey = require('@blocklet/meta/lib/has-reserved-key');
23
22
  const urlPathFriendly = require('@blocklet/meta/lib/url-path-friendly').default;
24
- const { ROLES, WELLKNOWN_SERVICE_PATH_PREFIX, WELLKNOWN_DID_RESOLVER_PREFIX } = require('@abtnode/constant');
25
- const { getDidDomainForBlocklet } = require('@abtnode/util/lib/get-domain-for-blocklet');
23
+ const { ROLES, WELLKNOWN_SERVICE_PATH_PREFIX } = require('@abtnode/constant');
24
+ const ensureServerEndpoint = require('@abtnode/util/lib/ensure-server-endpoint');
25
+ const makeFormData = require('@abtnode/util/lib/make-from-data');
26
26
 
27
27
  const { createConnect } = require('@blocklet/store');
28
28
  const open = require('open');
@@ -47,8 +47,6 @@ const debug = require('../../debug')('blocklet:deploy');
47
47
  const { signWithAccessKey, validateAccessKey } = Client;
48
48
  const { fileFilter, printDeployFileInfo } = deployManager;
49
49
 
50
- const BLOCKLET_JSON_PATH = '__blocklet__.js?type=json';
51
-
52
50
  async function confirmOpenConnectPage(
53
51
  message = 'No access key found, do you need to open the connect page to generate access key?'
54
52
  ) {
@@ -64,64 +62,6 @@ async function confirmOpenConnectPage(
64
62
  return isOpenConnectPage;
65
63
  }
66
64
 
67
- const makeFormData = ({ tarFile: file, hasDiff, did, serverVersion, deleteSet, rootDid, mountPoint }) => {
68
- let varFields = hasDiff
69
- ? '$file: Upload!, $did: String, $diffVersion: String, $deleteSet: [String!]'
70
- : '$file: Upload!';
71
- let inputFields = hasDiff
72
- ? 'file: $file, did: $did, diffVersion: $diffVersion, deleteSet: $deleteSet'
73
- : 'file: $file';
74
-
75
- varFields = `${varFields}, $rootDid: String, $mountPoint: String`;
76
- inputFields = `${inputFields}, rootDid: $rootDid, mountPoint: $mountPoint`;
77
-
78
- const variables = hasDiff
79
- ? {
80
- file: null,
81
- did,
82
- diffVersion: serverVersion,
83
- deleteSet,
84
- }
85
- : {
86
- file: null,
87
- };
88
-
89
- variables.rootDid = rootDid;
90
- variables.mountPoint = mountPoint;
91
-
92
- const apiName = 'installComponent';
93
- const query = `
94
- mutation (${varFields}) {
95
- ${apiName}(input: { ${inputFields} } ) {
96
- code
97
- blocklet {
98
- meta {
99
- did
100
- name
101
- title
102
- version
103
- description
104
- }
105
- status
106
- source
107
- }
108
- }
109
- }
110
- `;
111
- const gql = {
112
- query,
113
- variables,
114
- };
115
- const map = {
116
- file0: ['variables.file'],
117
- };
118
- const form = new FormData();
119
- form.append('operations', JSON.stringify(gql));
120
- form.append('map', JSON.stringify(map));
121
- form.append('file0', fs.createReadStream(file));
122
- return { form, apiName };
123
- };
124
-
125
65
  const deploy = async (dir, { endpoint, accessKey, accessSecret, appDid, appId, mountPoint: inputMountPoint }) => {
126
66
  let bundleDir = dir;
127
67
  if (fs.existsSync(path.join(dir, BLOCKLET_BUNDLE_FOLDER))) {
@@ -439,7 +379,7 @@ const createConnectForGenerateAccessKey = async (dir, opts) => {
439
379
  enableEncrypt: true,
440
380
  wrapSpinner,
441
381
  openPage: open,
442
- source: 'Generate Access Key',
382
+ source: 'connect to blocklet cli',
443
383
  prettyUrl: (url) => chalk.cyan(url),
444
384
  });
445
385
 
@@ -496,51 +436,6 @@ const checkLocalAccessKey = async (dir, opts) => {
496
436
  }
497
437
  };
498
438
 
499
- const ensureServerEndpoint = async (endpoint) => {
500
- let serverBaseUrl;
501
- let appPid;
502
-
503
- const jsonPathUrl = joinURL(new URL(endpoint).origin, BLOCKLET_JSON_PATH);
504
-
505
- const checkEndpoint = await axios(jsonPathUrl).catch(() => null);
506
- const contentType = checkEndpoint && checkEndpoint.headers['content-type'];
507
- if (contentType?.includes('application/json')) {
508
- const url = getDidDomainForBlocklet({ did: checkEndpoint.data.serverDid });
509
- // service endpoint
510
- serverBaseUrl = new URL(`https://${url}`).origin;
511
- appPid = checkEndpoint.data.appPid;
512
- } else {
513
- // maybe server endpoint
514
- serverBaseUrl = new URL(endpoint).origin;
515
- appPid = '';
516
- }
517
-
518
- if (!serverBaseUrl) {
519
- throw new Error('Invalid endpoint');
520
- }
521
-
522
- // local debug
523
- if (serverBaseUrl.includes('localhost:3000')) {
524
- return {
525
- endpoint: serverBaseUrl,
526
- appPid,
527
- };
528
- }
529
-
530
- const didJsonUrl = joinURL(serverBaseUrl, WELLKNOWN_DID_RESOLVER_PREFIX);
531
- const didJson = await axios(didJsonUrl);
532
-
533
- const didJsonContentType = didJson.headers['content-type'];
534
- if (!didJsonContentType.includes('application/json')) {
535
- throw new Error('Invalid endpoint');
536
- }
537
-
538
- return {
539
- endpoint: joinURL(serverBaseUrl, didJson?.data?.services?.[0]?.path),
540
- appPid,
541
- };
542
- };
543
-
544
439
  const verifyEndpoint = async (opts) => {
545
440
  const { endpoint, appPid } = await ensureServerEndpoint(opts.endpoint);
546
441
  opts.connectEndpoint = opts.endpoint;
@@ -1,59 +1,8 @@
1
1
  const chalk = require('chalk');
2
- const { minimatch } = require('minimatch');
2
+ const { fileFilter, checkMatch } = require('@abtnode/util/lib/check-file');
3
3
 
4
4
  const { print, printInfo } = require('../util');
5
5
 
6
- const checkMatch = (file, match) => {
7
- let m = match;
8
- if (!m.includes('*')) {
9
- return false;
10
- }
11
- if (!m.endsWith('*')) {
12
- return minimatch(file, m);
13
- }
14
- if (!m.endsWith('**')) {
15
- m = `${m}*`;
16
- }
17
-
18
- return minimatch(file, m);
19
- };
20
-
21
- const checkInclude = (list, f) =>
22
- f === '.' ||
23
- f === '' || // root folder maybe '.' and ''
24
- list.some(
25
- (x) =>
26
- x.indexOf(f) === 0 || // f is 'website' && x is 'website/public'
27
- f.indexOf(x) === 0 || // f is website/public/index.html && x is website/public
28
- checkMatch(f, x) // f is hooks/pre-start.js && x is hooks/*
29
- );
30
-
31
- /**
32
- * Whether a file should be deployed
33
- * @param {string} file a file will be deployed
34
- * @param {object} opts
35
- * @param {array<string>} opts.diffList
36
- * @param {BundleType} opts.bundleType
37
- * @param {array<string>} opts.staticList
38
- * @return {boolean} Should this file be deployed
39
- */
40
- const fileFilter = (file, opts = {}) => {
41
- const { diffList, bundleType, staticList } = opts;
42
- // only include diffList if has one
43
- if (diffList) {
44
- return checkInclude(diffList, file);
45
- }
46
- // only include staticList if bundleType is static
47
- if (bundleType === 'static') {
48
- if (!staticList) {
49
- throw new Error('staticList should not be empty when bundleType is static');
50
- }
51
- return checkInclude(staticList, file);
52
- }
53
- // include all files
54
- return true;
55
- };
56
-
57
6
  const printDeployFileInfo = (adds, changes, deletes) => {
58
7
  const padLeft = ' - ';
59
8
  printInfo(`Added Files: ${chalk.cyan(adds.length)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/cli",
3
- "version": "1.16.43-beta-20250422-042711-c40bec75",
3
+ "version": "1.16.43-beta-20250425-130658-8da18f4d",
4
4
  "description": "Command line tools to manage Blocklet Server",
5
5
  "homepage": "https://github.com/ArcBlock/blocklet-server#readme",
6
6
  "bin": {
@@ -35,30 +35,30 @@
35
35
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
36
36
  },
37
37
  "dependencies": {
38
- "@abtnode/blocklet-services": "1.16.43-beta-20250422-042711-c40bec75",
39
- "@abtnode/client": "1.16.43-beta-20250422-042711-c40bec75",
40
- "@abtnode/constant": "1.16.43-beta-20250422-042711-c40bec75",
41
- "@abtnode/core": "1.16.43-beta-20250422-042711-c40bec75",
42
- "@abtnode/logger": "1.16.43-beta-20250422-042711-c40bec75",
43
- "@abtnode/router-provider": "1.16.43-beta-20250422-042711-c40bec75",
44
- "@abtnode/util": "1.16.43-beta-20250422-042711-c40bec75",
45
- "@abtnode/webapp": "1.16.43-beta-20250422-042711-c40bec75",
46
- "@arcblock/did": "1.20.1",
47
- "@arcblock/event-hub": "1.20.1",
38
+ "@abtnode/blocklet-services": "1.16.43-beta-20250425-130658-8da18f4d",
39
+ "@abtnode/client": "1.16.43-beta-20250425-130658-8da18f4d",
40
+ "@abtnode/constant": "1.16.43-beta-20250425-130658-8da18f4d",
41
+ "@abtnode/core": "1.16.43-beta-20250425-130658-8da18f4d",
42
+ "@abtnode/logger": "1.16.43-beta-20250425-130658-8da18f4d",
43
+ "@abtnode/router-provider": "1.16.43-beta-20250425-130658-8da18f4d",
44
+ "@abtnode/util": "1.16.43-beta-20250425-130658-8da18f4d",
45
+ "@abtnode/webapp": "1.16.43-beta-20250425-130658-8da18f4d",
46
+ "@arcblock/did": "1.20.2",
47
+ "@arcblock/event-hub": "1.20.2",
48
48
  "@arcblock/ipfs-only-hash": "^0.0.2",
49
- "@arcblock/jwt": "1.20.1",
50
- "@arcblock/ws": "1.20.1",
51
- "@blocklet/constant": "1.16.43-beta-20250422-042711-c40bec75",
49
+ "@arcblock/jwt": "1.20.2",
50
+ "@arcblock/ws": "1.20.2",
51
+ "@blocklet/constant": "1.16.43-beta-20250425-130658-8da18f4d",
52
52
  "@blocklet/form-collector": "^0.1.8",
53
- "@blocklet/images": "1.16.43-beta-20250422-042711-c40bec75",
54
- "@blocklet/meta": "1.16.43-beta-20250422-042711-c40bec75",
55
- "@blocklet/resolver": "1.16.43-beta-20250422-042711-c40bec75",
56
- "@blocklet/store": "1.16.43-beta-20250422-042711-c40bec75",
53
+ "@blocklet/images": "1.16.43-beta-20250425-130658-8da18f4d",
54
+ "@blocklet/meta": "1.16.43-beta-20250425-130658-8da18f4d",
55
+ "@blocklet/resolver": "1.16.43-beta-20250425-130658-8da18f4d",
56
+ "@blocklet/store": "1.16.43-beta-20250425-130658-8da18f4d",
57
57
  "@blocklet/theme-builder": "^0.1.11",
58
- "@ocap/client": "1.20.1",
59
- "@ocap/mcrypto": "1.20.1",
60
- "@ocap/util": "1.20.1",
61
- "@ocap/wallet": "1.20.1",
58
+ "@ocap/client": "1.20.2",
59
+ "@ocap/mcrypto": "1.20.2",
60
+ "@ocap/util": "1.20.2",
61
+ "@ocap/wallet": "1.20.2",
62
62
  "@vercel/ncc": "^0.38.3",
63
63
  "archiver": "^7.0.1",
64
64
  "async": "^3.2.4",
@@ -152,7 +152,7 @@
152
152
  "engines": {
153
153
  "node": ">=14"
154
154
  },
155
- "gitHead": "836a400c1f953f421a8e95dc9a32ba883ac2586d",
155
+ "gitHead": "b5195a0290d5ced00bb716a709548b1a56356134",
156
156
  "devDependencies": {
157
157
  "@types/fs-extra": "^11.0.4",
158
158
  "@types/jest": "^29.5.13"