ic-mops 0.29.0-0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.ts CHANGED
@@ -24,6 +24,7 @@ import {bump} from './commands/bump.js';
24
24
  import {sync} from './commands/sync.js';
25
25
  import {outdated} from './commands/outdated.js';
26
26
  import {update} from './commands/update.js';
27
+ import {transferOwnership} from './commands/transfer-ownership.js';
27
28
  // import {docs} from './commands/docs.js';
28
29
 
29
30
  program.name('mops');
@@ -317,4 +318,12 @@ program
317
318
  await update(pkg);
318
319
  });
319
320
 
321
+ // transfer-ownership
322
+ program
323
+ .command('transfer-ownership [to-principal]')
324
+ .description('Transfer ownership of the current package to another principal')
325
+ .action(async (toPrincipal) => {
326
+ await transferOwnership(toPrincipal);
327
+ });
328
+
320
329
  program.parse();
package/commands/add.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import chalk from 'chalk';
3
3
  import logUpdate from 'log-update';
4
- import {checkConfigFile, getGithubCommit, getHighestVersion, parseGithubURL, readConfig, writeConfig} from '../mops.js';
4
+ import {checkConfigFile, getHighestVersion, parseGithubURL, readConfig, writeConfig} from '../mops.js';
5
5
  import {installFromGithub} from '../vessel.js';
6
6
  import {install} from './install.js';
7
7
  import {notifyInstalls} from '../notify-installs.js';
@@ -36,20 +36,11 @@ export async function add(name: string, {verbose = false, dev = false} = {}) {
36
36
  }
37
37
  // github package
38
38
  else if (name.startsWith('https://github.com') || name.split('/').length > 1) {
39
- let {org, gitName, branch, commitHash} = parseGithubURL(name);
40
-
41
- // fetch latest commit hash of branch if not specified
42
- if (!commitHash) {
43
- let commit = await getGithubCommit(`${org}/${gitName}`, branch);
44
- if (!commit.sha) {
45
- throw Error(`Could not find commit hash for ${name}`);
46
- }
47
- commitHash = commit.sha;
48
- }
39
+ const {org, gitName, branch} = parseGithubURL(name);
49
40
 
50
41
  pkgDetails = {
51
42
  name: parseGithubURL(name).gitName,
52
- repo: `https://github.com/${org}/${gitName}#${branch}@${commitHash}`,
43
+ repo: `https://github.com/${org}/${gitName}#${branch}`,
53
44
  version: '',
54
45
  };
55
46
  }
package/commands/init.ts CHANGED
@@ -174,15 +174,22 @@ async function applyInit({type, config, setupWorkflow, addTest, copyrightOwner}
174
174
  let dfxJsonData;
175
175
  if (existsSync(dfxJson)) {
176
176
  let dfxJsonText = readFileSync(dfxJson).toString();
177
- dfxJsonData = JSON.parse(dfxJsonText);
178
- console.log('Setting packtool in dfx.json...');
179
- dfxJsonData.defaults = dfxJsonData.defaults || {};
180
- dfxJsonData.defaults.build = dfxJsonData.defaults.build || {};
181
- if (dfxJsonData.defaults.build.packtool !== 'mops sources') {
182
- dfxJsonData.defaults.build.packtool = 'mops sources';
183
- let indent = dfxJsonText.match(/([ \t]+)"/)?.[1] || ' ';
184
- writeFileSync(path.join(process.cwd(), 'dfx.json'), JSON.stringify(dfxJsonData, null, indent));
185
- console.log(chalk.green('packtool set to "mops sources"'));
177
+ try {
178
+ dfxJsonData = JSON.parse(dfxJsonText);
179
+ }
180
+ catch (err) {
181
+ console.log(chalk.yellow('Failed to parse dfx.json'));
182
+ }
183
+ if (dfxJsonData) {
184
+ console.log('Setting packtool in dfx.json...');
185
+ dfxJsonData.defaults = dfxJsonData.defaults || {};
186
+ dfxJsonData.defaults.build = dfxJsonData.defaults.build || {};
187
+ if (dfxJsonData.defaults.build.packtool !== 'mops sources') {
188
+ dfxJsonData.defaults.build.packtool = 'mops sources';
189
+ let indent = dfxJsonText.match(/([ \t]+)"/)?.[1] || ' ';
190
+ writeFileSync(path.join(process.cwd(), 'dfx.json'), JSON.stringify(dfxJsonData, null, indent));
191
+ console.log(chalk.green('packtool set to "mops sources"'));
192
+ }
186
193
  }
187
194
  }
188
195
 
@@ -0,0 +1,42 @@
1
+ import chalk from 'chalk';
2
+ import {checkConfigFile, mainActor, readConfig} from '../mops.js';
3
+ import {Principal} from '@dfinity/principal';
4
+ import prompts from 'prompts';
5
+
6
+ export async function transferOwnership(toPrincipal: string) {
7
+ if (!checkConfigFile()) {
8
+ return;
9
+ }
10
+
11
+ let config = readConfig();
12
+ let principal = Principal.fromText(toPrincipal);
13
+
14
+ let promptsConfig = {
15
+ onCancel() {
16
+ console.log('aborted');
17
+ process.exit(0);
18
+ }
19
+ };
20
+
21
+ console.log(chalk.red('Warning: ') + 'This action cannot be undone!');
22
+ let {confirm} = await prompts({
23
+ type: 'confirm',
24
+ name: 'confirm',
25
+ message: `Are you sure you want to transfer ownership of ${chalk.yellow(config.package?.name)} to ${chalk.yellow(toPrincipal)}?`,
26
+ initial: false,
27
+ }, promptsConfig);
28
+
29
+ if (!confirm) {
30
+ return;
31
+ }
32
+
33
+ let actor = await mainActor(true);
34
+
35
+ let res = await actor.transferOwnership(config.package?.name || '', principal);
36
+ if ('ok' in res) {
37
+ console.log(chalk.green('Success!'));
38
+ }
39
+ else {
40
+ console.log(chalk.red('Error: ') + res.err);
41
+ }
42
+ }
@@ -1,5 +1,5 @@
1
1
  import chalk from 'chalk';
2
- import {checkConfigFile, getGithubCommit, parseGithubURL, readConfig} from '../mops.js';
2
+ import {checkConfigFile, readConfig} from '../mops.js';
3
3
  import {add} from './add.js';
4
4
  import {getAvailableUpdates} from './available-updates.js';
5
5
 
@@ -9,38 +9,10 @@ export async function update(pkg?: string) {
9
9
  }
10
10
  let config = readConfig();
11
11
 
12
- if (pkg && !config.dependencies?.[pkg] && !config['dev-dependencies']?.[pkg]) {
13
- console.log(chalk.red(`Package "${pkg}" is not installed!`));
14
- return;
15
- }
16
-
17
- // update github packages
18
- let deps = Object.values(config.dependencies || {});
19
- let devDeps = Object.values(config['dev-dependencies'] || {});
20
- let githubDeps = [...deps, ...devDeps].filter((dep) => dep.repo);
21
- if (pkg) {
22
- githubDeps = githubDeps.filter((dep) => dep.name === pkg);
23
- }
24
-
25
- for (let dep of githubDeps) {
26
- let {org, gitName, branch, commitHash} = parseGithubURL(dep.repo || '');
27
- let dev = !!config['dev-dependencies']?.[dep.name];
28
- let commit = await getGithubCommit(`${org}/${gitName}`, branch);
29
- if (commit.sha !== commitHash) {
30
- await add(`https://github.com/${org}/${gitName}#${branch}@${commitHash}`, {dev});
31
- }
32
- }
33
-
34
- // update mops packages
35
12
  let available = await getAvailableUpdates(config, pkg);
36
13
 
37
14
  if (available.length === 0) {
38
- if (pkg) {
39
- console.log(chalk.green(`Package "${pkg}" is up to date!`));
40
- }
41
- else {
42
- console.log(chalk.green('All dependencies are up to date!'));
43
- }
15
+ console.log(chalk.green('All dependencies are up to date!'));
44
16
  }
45
17
  else {
46
18
  for (let dep of available) {
@@ -82,7 +82,7 @@ type Result_6 =
82
82
  variant {
83
83
  err: Err;
84
84
  ok: vec record {
85
- PackageName__1;
85
+ PackageName;
86
86
  PackageVersion;
87
87
  };
88
88
  };
@@ -97,20 +97,20 @@ type Result_4 =
97
97
  ok: PackageDetails;
98
98
  };
99
99
  type Result_3 =
100
- variant {
101
- err: text;
102
- ok;
103
- };
104
- type Result_2 =
105
100
  variant {
106
101
  err: Err;
107
102
  ok: FileId;
108
103
  };
109
- type Result_1 =
104
+ type Result_2 =
110
105
  variant {
111
106
  err: PublishingErr;
112
107
  ok: PublishingId;
113
108
  };
109
+ type Result_1 =
110
+ variant {
111
+ err: text;
112
+ ok;
113
+ };
114
114
  type Result =
115
115
  variant {
116
116
  err: Err;
@@ -223,7 +223,7 @@ type PackageConfigV2__1 =
223
223
  keywords: vec text;
224
224
  license: text;
225
225
  moc: text;
226
- name: PackageName;
226
+ name: PackageName__1;
227
227
  readme: text;
228
228
  repository: text;
229
229
  scripts: vec Script;
@@ -242,7 +242,7 @@ type PackageConfigV2 =
242
242
  keywords: vec text;
243
243
  license: text;
244
244
  moc: text;
245
- name: PackageName;
245
+ name: PackageName__1;
246
246
  readme: text;
247
247
  repository: text;
248
248
  scripts: vec Script;
@@ -283,7 +283,7 @@ type DownloadsSnapshot =
283
283
  };
284
284
  type DependencyV2 =
285
285
  record {
286
- name: PackageName;
286
+ name: PackageName__1;
287
287
  repo: text;
288
288
  version: text;
289
289
  };
@@ -304,25 +304,25 @@ service : {
304
304
  getBackupCanisterId: () -> (principal) query;
305
305
  getDefaultPackages: (text) ->
306
306
  (vec record {
307
- PackageName__1;
307
+ PackageName;
308
308
  PackageVersion;
309
309
  }) query;
310
310
  getDownloadTrendByPackageId: (PackageId) ->
311
311
  (vec DownloadsSnapshot__1) query;
312
- getDownloadTrendByPackageName: (PackageName__1) ->
312
+ getDownloadTrendByPackageName: (PackageName) ->
313
313
  (vec DownloadsSnapshot__1) query;
314
- getFileIds: (PackageName__1, PackageVersion) -> (Result_7) query;
314
+ getFileIds: (PackageName, PackageVersion) -> (Result_7) query;
315
315
  getHighestSemverBatch:
316
316
  (vec record {
317
- PackageName__1;
317
+ PackageName;
318
318
  PackageVersion;
319
319
  SemverPart;
320
320
  }) -> (Result_6) query;
321
- getHighestVersion: (PackageName__1) -> (Result_5) query;
321
+ getHighestVersion: (PackageName) -> (Result_5) query;
322
322
  getMostDownloadedPackages: () -> (vec PackageSummary) query;
323
323
  getMostDownloadedPackagesIn7Days: () -> (vec PackageSummary) query;
324
324
  getNewPackages: () -> (vec PackageSummary) query;
325
- getPackageDetails: (PackageName__1, PackageVersion) -> (Result_4) query;
325
+ getPackageDetails: (PackageName, PackageVersion) -> (Result_4) query;
326
326
  getPackagesByCategory: () -> (vec record {
327
327
  text;
328
328
  vec PackageSummary;
@@ -336,17 +336,18 @@ service : {
336
336
  getTotalPackages: () -> (nat) query;
337
337
  getUser: (principal) -> (opt User__1) query;
338
338
  http_request: (Request) -> (Response) query;
339
- notifyInstall: (PackageName__1, PackageVersion) -> () oneway;
339
+ notifyInstall: (PackageName, PackageVersion) -> () oneway;
340
340
  notifyInstalls: (vec record {
341
- PackageName__1;
341
+ PackageName;
342
342
  PackageVersion;
343
343
  }) -> () oneway;
344
344
  restore: (nat, nat) -> ();
345
345
  search: (Text, opt nat, opt nat) -> (vec PackageSummary, PageCount) query;
346
- setUserProp: (text, text) -> (Result_3);
347
- startFileUpload: (PublishingId, Text, nat, blob) -> (Result_2);
348
- startPublish: (PackageConfigV2) -> (Result_1);
346
+ setUserProp: (text, text) -> (Result_1);
347
+ startFileUpload: (PublishingId, Text, nat, blob) -> (Result_3);
348
+ startPublish: (PackageConfigV2) -> (Result_2);
349
349
  takeAirdropSnapshot: () -> () oneway;
350
+ transferOwnership: (PackageName, principal) -> (Result_1);
350
351
  uploadFileChunk: (PublishingId, FileId, nat, blob) -> (Result);
351
352
  uploadNotes: (PublishingId, text) -> (Result);
352
353
  uploadTestStats: (PublishingId, TestStats) -> (Result);
@@ -7,7 +7,7 @@ export interface DepChange {
7
7
  'newVersion' : string,
8
8
  }
9
9
  export interface DependencyV2 {
10
- 'name' : PackageName,
10
+ 'name' : PackageName__1,
11
11
  'repo' : string,
12
12
  'version' : string,
13
13
  }
@@ -42,7 +42,7 @@ export interface PackageConfigV2 {
42
42
  'scripts' : Array<Script>,
43
43
  'baseDir' : string,
44
44
  'documentation' : string,
45
- 'name' : PackageName,
45
+ 'name' : PackageName__1,
46
46
  'homepage' : string,
47
47
  'description' : string,
48
48
  'version' : string,
@@ -60,7 +60,7 @@ export interface PackageConfigV2__1 {
60
60
  'scripts' : Array<Script>,
61
61
  'baseDir' : string,
62
62
  'documentation' : string,
63
- 'name' : PackageName,
63
+ 'name' : PackageName__1,
64
64
  'homepage' : string,
65
65
  'description' : string,
66
66
  'version' : string,
@@ -159,17 +159,17 @@ export interface Response {
159
159
  }
160
160
  export type Result = { 'ok' : null } |
161
161
  { 'err' : Err };
162
- export type Result_1 = { 'ok' : PublishingId } |
162
+ export type Result_1 = { 'ok' : null } |
163
+ { 'err' : string };
164
+ export type Result_2 = { 'ok' : PublishingId } |
163
165
  { 'err' : PublishingErr };
164
- export type Result_2 = { 'ok' : FileId } |
166
+ export type Result_3 = { 'ok' : FileId } |
165
167
  { 'err' : Err };
166
- export type Result_3 = { 'ok' : null } |
167
- { 'err' : string };
168
168
  export type Result_4 = { 'ok' : PackageDetails } |
169
169
  { 'err' : Err };
170
170
  export type Result_5 = { 'ok' : PackageVersion } |
171
171
  { 'err' : Err };
172
- export type Result_6 = { 'ok' : Array<[PackageName__1, PackageVersion]> } |
172
+ export type Result_6 = { 'ok' : Array<[PackageName, PackageVersion]> } |
173
173
  { 'err' : Err };
174
174
  export type Result_7 = { 'ok' : Array<FileId> } |
175
175
  { 'err' : Err };
@@ -241,26 +241,26 @@ export interface _SERVICE {
241
241
  'getBackupCanisterId' : ActorMethod<[], Principal>,
242
242
  'getDefaultPackages' : ActorMethod<
243
243
  [string],
244
- Array<[PackageName__1, PackageVersion]>
244
+ Array<[PackageName, PackageVersion]>
245
245
  >,
246
246
  'getDownloadTrendByPackageId' : ActorMethod<
247
247
  [PackageId],
248
248
  Array<DownloadsSnapshot__1>
249
249
  >,
250
250
  'getDownloadTrendByPackageName' : ActorMethod<
251
- [PackageName__1],
251
+ [PackageName],
252
252
  Array<DownloadsSnapshot__1>
253
253
  >,
254
- 'getFileIds' : ActorMethod<[PackageName__1, PackageVersion], Result_7>,
254
+ 'getFileIds' : ActorMethod<[PackageName, PackageVersion], Result_7>,
255
255
  'getHighestSemverBatch' : ActorMethod<
256
- [Array<[PackageName__1, PackageVersion, SemverPart]>],
256
+ [Array<[PackageName, PackageVersion, SemverPart]>],
257
257
  Result_6
258
258
  >,
259
- 'getHighestVersion' : ActorMethod<[PackageName__1], Result_5>,
259
+ 'getHighestVersion' : ActorMethod<[PackageName], Result_5>,
260
260
  'getMostDownloadedPackages' : ActorMethod<[], Array<PackageSummary>>,
261
261
  'getMostDownloadedPackagesIn7Days' : ActorMethod<[], Array<PackageSummary>>,
262
262
  'getNewPackages' : ActorMethod<[], Array<PackageSummary>>,
263
- 'getPackageDetails' : ActorMethod<[PackageName__1, PackageVersion], Result_4>,
263
+ 'getPackageDetails' : ActorMethod<[PackageName, PackageVersion], Result_4>,
264
264
  'getPackagesByCategory' : ActorMethod<
265
265
  [],
266
266
  Array<[string, Array<PackageSummary>]>
@@ -274,9 +274,9 @@ export interface _SERVICE {
274
274
  'getTotalPackages' : ActorMethod<[], bigint>,
275
275
  'getUser' : ActorMethod<[Principal], [] | [User__1]>,
276
276
  'http_request' : ActorMethod<[Request], Response>,
277
- 'notifyInstall' : ActorMethod<[PackageName__1, PackageVersion], undefined>,
277
+ 'notifyInstall' : ActorMethod<[PackageName, PackageVersion], undefined>,
278
278
  'notifyInstalls' : ActorMethod<
279
- [Array<[PackageName__1, PackageVersion]>],
279
+ [Array<[PackageName, PackageVersion]>],
280
280
  undefined
281
281
  >,
282
282
  'restore' : ActorMethod<[bigint, bigint], undefined>,
@@ -284,13 +284,14 @@ export interface _SERVICE {
284
284
  [Text, [] | [bigint], [] | [bigint]],
285
285
  [Array<PackageSummary>, PageCount]
286
286
  >,
287
- 'setUserProp' : ActorMethod<[string, string], Result_3>,
287
+ 'setUserProp' : ActorMethod<[string, string], Result_1>,
288
288
  'startFileUpload' : ActorMethod<
289
289
  [PublishingId, Text, bigint, Uint8Array | number[]],
290
- Result_2
290
+ Result_3
291
291
  >,
292
- 'startPublish' : ActorMethod<[PackageConfigV2], Result_1>,
292
+ 'startPublish' : ActorMethod<[PackageConfigV2], Result_2>,
293
293
  'takeAirdropSnapshot' : ActorMethod<[], undefined>,
294
+ 'transferOwnership' : ActorMethod<[PackageName, Principal], Result_1>,
294
295
  'uploadFileChunk' : ActorMethod<
295
296
  [PublishingId, FileId, bigint, Uint8Array | number[]],
296
297
  Result
@@ -18,7 +18,7 @@ export const idlFactory = ({ IDL }) => {
18
18
  const Err = IDL.Text;
19
19
  const Result = IDL.Variant({ 'ok' : IDL.Null, 'err' : Err });
20
20
  const Text = IDL.Text;
21
- const PackageName__1 = IDL.Text;
21
+ const PackageName = IDL.Text;
22
22
  const PackageVersion = IDL.Text;
23
23
  const PackageId = IDL.Text;
24
24
  const Time = IDL.Int;
@@ -35,7 +35,7 @@ export const idlFactory = ({ IDL }) => {
35
35
  'patch' : IDL.Null,
36
36
  });
37
37
  const Result_6 = IDL.Variant({
38
- 'ok' : IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion)),
38
+ 'ok' : IDL.Vec(IDL.Tuple(PackageName, PackageVersion)),
39
39
  'err' : Err,
40
40
  });
41
41
  const Result_5 = IDL.Variant({ 'ok' : PackageVersion, 'err' : Err });
@@ -52,9 +52,9 @@ export const idlFactory = ({ IDL }) => {
52
52
  'github' : IDL.Text,
53
53
  });
54
54
  const Script = IDL.Record({ 'value' : IDL.Text, 'name' : IDL.Text });
55
- const PackageName = IDL.Text;
55
+ const PackageName__1 = IDL.Text;
56
56
  const DependencyV2 = IDL.Record({
57
- 'name' : PackageName,
57
+ 'name' : PackageName__1,
58
58
  'repo' : IDL.Text,
59
59
  'version' : IDL.Text,
60
60
  });
@@ -64,7 +64,7 @@ export const idlFactory = ({ IDL }) => {
64
64
  'scripts' : IDL.Vec(Script),
65
65
  'baseDir' : IDL.Text,
66
66
  'documentation' : IDL.Text,
67
- 'name' : PackageName,
67
+ 'name' : PackageName__1,
68
68
  'homepage' : IDL.Text,
69
69
  'description' : IDL.Text,
70
70
  'version' : IDL.Text,
@@ -206,15 +206,15 @@ export const idlFactory = ({ IDL }) => {
206
206
  'status_code' : IDL.Nat16,
207
207
  });
208
208
  const PageCount = IDL.Nat;
209
- const Result_3 = IDL.Variant({ 'ok' : IDL.Null, 'err' : IDL.Text });
210
- const Result_2 = IDL.Variant({ 'ok' : FileId, 'err' : Err });
209
+ const Result_1 = IDL.Variant({ 'ok' : IDL.Null, 'err' : IDL.Text });
210
+ const Result_3 = IDL.Variant({ 'ok' : FileId, 'err' : Err });
211
211
  const PackageConfigV2 = IDL.Record({
212
212
  'dfx' : IDL.Text,
213
213
  'moc' : IDL.Text,
214
214
  'scripts' : IDL.Vec(Script),
215
215
  'baseDir' : IDL.Text,
216
216
  'documentation' : IDL.Text,
217
- 'name' : PackageName,
217
+ 'name' : PackageName__1,
218
218
  'homepage' : IDL.Text,
219
219
  'description' : IDL.Text,
220
220
  'version' : IDL.Text,
@@ -227,7 +227,7 @@ export const idlFactory = ({ IDL }) => {
227
227
  'readme' : IDL.Text,
228
228
  });
229
229
  const PublishingErr = IDL.Text;
230
- const Result_1 = IDL.Variant({ 'ok' : PublishingId, 'err' : PublishingErr });
230
+ const Result_2 = IDL.Variant({ 'ok' : PublishingId, 'err' : PublishingErr });
231
231
  const TestStats = IDL.Record({
232
232
  'passedNames' : IDL.Vec(IDL.Text),
233
233
  'passed' : IDL.Nat,
@@ -243,7 +243,7 @@ export const idlFactory = ({ IDL }) => {
243
243
  'getBackupCanisterId' : IDL.Func([], [IDL.Principal], ['query']),
244
244
  'getDefaultPackages' : IDL.Func(
245
245
  [IDL.Text],
246
- [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion))],
246
+ [IDL.Vec(IDL.Tuple(PackageName, PackageVersion))],
247
247
  ['query'],
248
248
  ),
249
249
  'getDownloadTrendByPackageId' : IDL.Func(
@@ -252,21 +252,21 @@ export const idlFactory = ({ IDL }) => {
252
252
  ['query'],
253
253
  ),
254
254
  'getDownloadTrendByPackageName' : IDL.Func(
255
- [PackageName__1],
255
+ [PackageName],
256
256
  [IDL.Vec(DownloadsSnapshot__1)],
257
257
  ['query'],
258
258
  ),
259
259
  'getFileIds' : IDL.Func(
260
- [PackageName__1, PackageVersion],
260
+ [PackageName, PackageVersion],
261
261
  [Result_7],
262
262
  ['query'],
263
263
  ),
264
264
  'getHighestSemverBatch' : IDL.Func(
265
- [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion, SemverPart))],
265
+ [IDL.Vec(IDL.Tuple(PackageName, PackageVersion, SemverPart))],
266
266
  [Result_6],
267
267
  ['query'],
268
268
  ),
269
- 'getHighestVersion' : IDL.Func([PackageName__1], [Result_5], ['query']),
269
+ 'getHighestVersion' : IDL.Func([PackageName], [Result_5], ['query']),
270
270
  'getMostDownloadedPackages' : IDL.Func(
271
271
  [],
272
272
  [IDL.Vec(PackageSummary)],
@@ -279,7 +279,7 @@ export const idlFactory = ({ IDL }) => {
279
279
  ),
280
280
  'getNewPackages' : IDL.Func([], [IDL.Vec(PackageSummary)], ['query']),
281
281
  'getPackageDetails' : IDL.Func(
282
- [PackageName__1, PackageVersion],
282
+ [PackageName, PackageVersion],
283
283
  [Result_4],
284
284
  ['query'],
285
285
  ),
@@ -302,13 +302,9 @@ export const idlFactory = ({ IDL }) => {
302
302
  'getTotalPackages' : IDL.Func([], [IDL.Nat], ['query']),
303
303
  'getUser' : IDL.Func([IDL.Principal], [IDL.Opt(User__1)], ['query']),
304
304
  'http_request' : IDL.Func([Request], [Response], ['query']),
305
- 'notifyInstall' : IDL.Func(
306
- [PackageName__1, PackageVersion],
307
- [],
308
- ['oneway'],
309
- ),
305
+ 'notifyInstall' : IDL.Func([PackageName, PackageVersion], [], ['oneway']),
310
306
  'notifyInstalls' : IDL.Func(
311
- [IDL.Vec(IDL.Tuple(PackageName__1, PackageVersion))],
307
+ [IDL.Vec(IDL.Tuple(PackageName, PackageVersion))],
312
308
  [],
313
309
  ['oneway'],
314
310
  ),
@@ -318,14 +314,19 @@ export const idlFactory = ({ IDL }) => {
318
314
  [IDL.Vec(PackageSummary), PageCount],
319
315
  ['query'],
320
316
  ),
321
- 'setUserProp' : IDL.Func([IDL.Text, IDL.Text], [Result_3], []),
317
+ 'setUserProp' : IDL.Func([IDL.Text, IDL.Text], [Result_1], []),
322
318
  'startFileUpload' : IDL.Func(
323
319
  [PublishingId, Text, IDL.Nat, IDL.Vec(IDL.Nat8)],
324
- [Result_2],
320
+ [Result_3],
325
321
  [],
326
322
  ),
327
- 'startPublish' : IDL.Func([PackageConfigV2], [Result_1], []),
323
+ 'startPublish' : IDL.Func([PackageConfigV2], [Result_2], []),
328
324
  'takeAirdropSnapshot' : IDL.Func([], [], ['oneway']),
325
+ 'transferOwnership' : IDL.Func(
326
+ [PackageName, IDL.Principal],
327
+ [Result_1],
328
+ [],
329
+ ),
329
330
  'uploadFileChunk' : IDL.Func(
330
331
  [PublishingId, FileId, IDL.Nat, IDL.Vec(IDL.Nat8)],
331
332
  [Result],
package/dist/cli.js CHANGED
@@ -22,6 +22,7 @@ import { bump } from './commands/bump.js';
22
22
  import { sync } from './commands/sync.js';
23
23
  import { outdated } from './commands/outdated.js';
24
24
  import { update } from './commands/update.js';
25
+ import { transferOwnership } from './commands/transfer-ownership.js';
25
26
  // import {docs} from './commands/docs.js';
26
27
  program.name('mops');
27
28
  // --version
@@ -288,4 +289,11 @@ program
288
289
  .action(async (pkg) => {
289
290
  await update(pkg);
290
291
  });
292
+ // transfer-ownership
293
+ program
294
+ .command('transfer-ownership [to-principal]')
295
+ .description('Transfer ownership of the current package to another principal')
296
+ .action(async (toPrincipal) => {
297
+ await transferOwnership(toPrincipal);
298
+ });
291
299
  program.parse();
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import chalk from 'chalk';
3
3
  import logUpdate from 'log-update';
4
- import { checkConfigFile, getGithubCommit, getHighestVersion, parseGithubURL, readConfig, writeConfig } from '../mops.js';
4
+ import { checkConfigFile, getHighestVersion, parseGithubURL, readConfig, writeConfig } from '../mops.js';
5
5
  import { installFromGithub } from '../vessel.js';
6
6
  import { install } from './install.js';
7
7
  import { notifyInstalls } from '../notify-installs.js';
@@ -32,18 +32,10 @@ export async function add(name, { verbose = false, dev = false } = {}) {
32
32
  }
33
33
  // github package
34
34
  else if (name.startsWith('https://github.com') || name.split('/').length > 1) {
35
- let { org, gitName, branch, commitHash } = parseGithubURL(name);
36
- // fetch latest commit hash of branch if not specified
37
- if (!commitHash) {
38
- let commit = await getGithubCommit(`${org}/${gitName}`, branch);
39
- if (!commit.sha) {
40
- throw Error(`Could not find commit hash for ${name}`);
41
- }
42
- commitHash = commit.sha;
43
- }
35
+ const { org, gitName, branch } = parseGithubURL(name);
44
36
  pkgDetails = {
45
37
  name: parseGithubURL(name).gitName,
46
- repo: `https://github.com/${org}/${gitName}#${branch}@${commitHash}`,
38
+ repo: `https://github.com/${org}/${gitName}#${branch}`,
47
39
  version: '',
48
40
  };
49
41
  }
@@ -146,15 +146,22 @@ async function applyInit({ type, config, setupWorkflow, addTest, copyrightOwner
146
146
  let dfxJsonData;
147
147
  if (existsSync(dfxJson)) {
148
148
  let dfxJsonText = readFileSync(dfxJson).toString();
149
- dfxJsonData = JSON.parse(dfxJsonText);
150
- console.log('Setting packtool in dfx.json...');
151
- dfxJsonData.defaults = dfxJsonData.defaults || {};
152
- dfxJsonData.defaults.build = dfxJsonData.defaults.build || {};
153
- if (dfxJsonData.defaults.build.packtool !== 'mops sources') {
154
- dfxJsonData.defaults.build.packtool = 'mops sources';
155
- let indent = dfxJsonText.match(/([ \t]+)"/)?.[1] || ' ';
156
- writeFileSync(path.join(process.cwd(), 'dfx.json'), JSON.stringify(dfxJsonData, null, indent));
157
- console.log(chalk.green('packtool set to "mops sources"'));
149
+ try {
150
+ dfxJsonData = JSON.parse(dfxJsonText);
151
+ }
152
+ catch (err) {
153
+ console.log(chalk.yellow('Failed to parse dfx.json'));
154
+ }
155
+ if (dfxJsonData) {
156
+ console.log('Setting packtool in dfx.json...');
157
+ dfxJsonData.defaults = dfxJsonData.defaults || {};
158
+ dfxJsonData.defaults.build = dfxJsonData.defaults.build || {};
159
+ if (dfxJsonData.defaults.build.packtool !== 'mops sources') {
160
+ dfxJsonData.defaults.build.packtool = 'mops sources';
161
+ let indent = dfxJsonText.match(/([ \t]+)"/)?.[1] || ' ';
162
+ writeFileSync(path.join(process.cwd(), 'dfx.json'), JSON.stringify(dfxJsonData, null, indent));
163
+ console.log(chalk.green('packtool set to "mops sources"'));
164
+ }
158
165
  }
159
166
  }
160
167
  // get default packages
@@ -0,0 +1 @@
1
+ export declare function transferOwnership(toPrincipal: string): Promise<void>;