@mimicprotocol/cli 0.0.1-rc.35 → 0.0.1-rc.36
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/CHANGELOG.md +6 -0
- package/README.md +10 -10
- package/dist/commands/build.js +5 -5
- package/dist/commands/compile.js +7 -7
- package/dist/commands/deploy.js +5 -5
- package/dist/commands/login.js +1 -1
- package/dist/commands/test.js +2 -2
- package/dist/lib/InputsInterfaceGenerator.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
|
|
28
28
|
The `mimic` CLI is a command-line interface to:
|
|
29
29
|
|
|
30
|
-
- Initialize a Mimic-compatible
|
|
31
|
-
- Generate types from your
|
|
32
|
-
- Compile your AssemblyScript
|
|
33
|
-
- Test your
|
|
34
|
-
- Deploy compiled
|
|
35
|
-
- Link
|
|
30
|
+
- Initialize a Mimic-compatible function project
|
|
31
|
+
- Generate types from your function manifest and ABIs
|
|
32
|
+
- Compile your AssemblyScript functions to WebAssembly
|
|
33
|
+
- Test your functions
|
|
34
|
+
- Deploy compiled functions to IPFS and the Mimic Registry
|
|
35
|
+
- Link functions to a project in the Mimic explorer
|
|
36
36
|
|
|
37
37
|
## Setup
|
|
38
38
|
|
|
@@ -64,15 +64,15 @@ COMMANDS
|
|
|
64
64
|
logout Remove stored credentials for a profile
|
|
65
65
|
profiles List all configured authentication profiles
|
|
66
66
|
codegen Generates typed interfaces for declared inputs and ABIs from your manifest.yaml file
|
|
67
|
-
compile Compiles
|
|
68
|
-
test Tests your
|
|
69
|
-
deploy Uploads your compiled
|
|
67
|
+
compile Compiles the function
|
|
68
|
+
test Tests your functions
|
|
69
|
+
deploy Uploads your compiled function artifacts to IPFS and registers it into the Mimic Registry
|
|
70
70
|
init Initializes a new Mimic-compatible project structure in the specified directory
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
### Authentication
|
|
74
74
|
|
|
75
|
-
Before deploying
|
|
75
|
+
Before deploying functions, you need to authenticate with your Mimic API key:
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
78
|
# Interactive login (recommended)
|
package/dist/commands/build.js
CHANGED
|
@@ -9,22 +9,22 @@ const compile_1 = __importDefault(require("./compile"));
|
|
|
9
9
|
class Build extends core_1.Command {
|
|
10
10
|
async run() {
|
|
11
11
|
const { flags } = await this.parse(Build);
|
|
12
|
-
const { manifest,
|
|
12
|
+
const { manifest, function: functionFile, output, types, clean } = flags;
|
|
13
13
|
const codegenArgs = ['--manifest', manifest, '--output', types];
|
|
14
14
|
if (clean)
|
|
15
15
|
codegenArgs.push('--clean');
|
|
16
16
|
await codegen_1.default.run(codegenArgs);
|
|
17
|
-
const compileArgs = ['--
|
|
17
|
+
const compileArgs = ['--function', functionFile, '--manifest', manifest, '--output', output];
|
|
18
18
|
await compile_1.default.run(compileArgs);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
Build.description = 'Runs code generation and then compiles the
|
|
21
|
+
Build.description = 'Runs code generation and then compiles the function';
|
|
22
22
|
Build.examples = [
|
|
23
|
-
'<%= config.bin %> <%= command.id %> --manifest ./manifest.yaml --
|
|
23
|
+
'<%= config.bin %> <%= command.id %> --manifest ./manifest.yaml --function src/function.ts --output ./build --types ./src/types',
|
|
24
24
|
];
|
|
25
25
|
Build.flags = {
|
|
26
26
|
manifest: core_1.Flags.string({ char: 'm', description: 'manifest to use', default: 'manifest.yaml' }),
|
|
27
|
-
|
|
27
|
+
function: core_1.Flags.string({ char: 'f', description: 'function to compile', default: 'src/function.ts' }),
|
|
28
28
|
output: core_1.Flags.string({ char: 'o', description: 'output directory for build artifacts', default: './build' }),
|
|
29
29
|
types: core_1.Flags.string({ char: 'y', description: 'output directory for generated types', default: './src/types' }),
|
|
30
30
|
clean: core_1.Flags.boolean({
|
package/dist/commands/compile.js
CHANGED
|
@@ -45,8 +45,8 @@ const log_1 = __importDefault(require("../log"));
|
|
|
45
45
|
class Compile extends core_1.Command {
|
|
46
46
|
async run() {
|
|
47
47
|
const { flags } = await this.parse(Compile);
|
|
48
|
-
const {
|
|
49
|
-
const
|
|
48
|
+
const { function: functionFile, output: outputDir, manifest: manifestDir } = flags;
|
|
49
|
+
const absFunctionFile = path.resolve(functionFile);
|
|
50
50
|
const absOutputDir = path.resolve(outputDir);
|
|
51
51
|
if (!fs.existsSync(absOutputDir))
|
|
52
52
|
fs.mkdirSync(absOutputDir, { recursive: true });
|
|
@@ -54,11 +54,11 @@ class Compile extends core_1.Command {
|
|
|
54
54
|
const manifest = ManifestHandler_1.default.load(this, manifestDir);
|
|
55
55
|
log_1.default.startAction('Compiling');
|
|
56
56
|
const ascArgs = [
|
|
57
|
-
|
|
57
|
+
absFunctionFile,
|
|
58
58
|
'--target',
|
|
59
59
|
'release',
|
|
60
60
|
'--outFile',
|
|
61
|
-
path.join(absOutputDir, '
|
|
61
|
+
path.join(absOutputDir, 'function.wasm'),
|
|
62
62
|
'--optimize',
|
|
63
63
|
'--exportRuntime',
|
|
64
64
|
'--transform',
|
|
@@ -77,10 +77,10 @@ class Compile extends core_1.Command {
|
|
|
77
77
|
console.log(`Build complete! Artifacts in ${outputDir}/`);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
Compile.description = 'Compiles
|
|
81
|
-
Compile.examples = ['<%= config.bin %> <%= command.id %> --
|
|
80
|
+
Compile.description = 'Compiles function';
|
|
81
|
+
Compile.examples = ['<%= config.bin %> <%= command.id %> --function src/function.ts --output ./output'];
|
|
82
82
|
Compile.flags = {
|
|
83
|
-
|
|
83
|
+
function: core_1.Flags.string({ char: 'f', description: 'function to compile', default: 'src/function.ts' }),
|
|
84
84
|
manifest: core_1.Flags.string({ char: 'm', description: 'manifest to validate', default: 'manifest.yaml' }),
|
|
85
85
|
output: core_1.Flags.string({ char: 'o', description: 'output directory', default: './build' }),
|
|
86
86
|
};
|
package/dist/commands/deploy.js
CHANGED
|
@@ -59,7 +59,7 @@ class Deploy extends authenticate_1.default {
|
|
|
59
59
|
this.error('Code generation failed', { code: 'CodegenError', suggestions: ['Fix manifest and ABI files'] });
|
|
60
60
|
const compile = (0, packageManager_1.execBinCommand)('mimic', ['compile', '--output', fullInputDir], process.cwd());
|
|
61
61
|
if (compile.status !== 0)
|
|
62
|
-
this.error('Compilation failed', { code: 'BuildError', suggestions: ['Check the
|
|
62
|
+
this.error('Compilation failed', { code: 'BuildError', suggestions: ['Check the function source code'] });
|
|
63
63
|
}
|
|
64
64
|
log_1.default.startAction('Validating');
|
|
65
65
|
if (!fs.existsSync(fullInputDir))
|
|
@@ -67,7 +67,7 @@ class Deploy extends authenticate_1.default {
|
|
|
67
67
|
code: 'Directory Not Found',
|
|
68
68
|
suggestions: ['Use the --input flag to specify the correct path'],
|
|
69
69
|
});
|
|
70
|
-
const neededFiles = ['manifest.json', '
|
|
70
|
+
const neededFiles = ['manifest.json', 'function.wasm'].map((file) => (0, path_1.join)(fullInputDir, file));
|
|
71
71
|
for (const file of neededFiles) {
|
|
72
72
|
if (!fs.existsSync(file))
|
|
73
73
|
this.error(`Could not find ${file}`, {
|
|
@@ -83,12 +83,12 @@ class Deploy extends authenticate_1.default {
|
|
|
83
83
|
fs.mkdirSync(fullOutputDir, { recursive: true });
|
|
84
84
|
fs.writeFileSync((0, path_1.join)(fullOutputDir, 'CID.json'), JSON.stringify({ CID }, null, 2));
|
|
85
85
|
console.log(`CID saved at ${log_1.default.highlightText(fullOutputDir)}`);
|
|
86
|
-
console.log(`
|
|
86
|
+
console.log(`Function deployed!`);
|
|
87
87
|
}
|
|
88
88
|
async uploadToRegistry(files, credentials, registryUrl) {
|
|
89
89
|
try {
|
|
90
90
|
const form = filesToForm(files);
|
|
91
|
-
const { data } = await axios_1.default.post(`${registryUrl}/
|
|
91
|
+
const { data } = await axios_1.default.post(`${registryUrl}/functions`, form, {
|
|
92
92
|
headers: {
|
|
93
93
|
'x-api-key': credentials.apiKey,
|
|
94
94
|
'Content-Type': `multipart/form-data; boundary=${form.getBoundary()}`,
|
|
@@ -115,7 +115,7 @@ class Deploy extends authenticate_1.default {
|
|
|
115
115
|
this.error(`${message} - ${err.message}`, { code: `${statusCode} Error`, suggestions: errors_1.GENERIC_SUGGESTION });
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
Deploy.description = 'Uploads your compiled
|
|
118
|
+
Deploy.description = 'Uploads your compiled function artifacts to IPFS and registers it into the Mimic Registry';
|
|
119
119
|
Deploy.examples = [
|
|
120
120
|
'<%= config.bin %> <%= command.id %> --input ./dist --output ./dist',
|
|
121
121
|
'<%= config.bin %> <%= command.id %> --profile staging',
|
package/dist/commands/login.js
CHANGED
|
@@ -73,7 +73,7 @@ class Login extends authenticate_1.default {
|
|
|
73
73
|
console.log(`✓ Credentials saved for profile ${log_1.default.highlightText(profileName)}`);
|
|
74
74
|
console.log(` Location: ${log_1.default.highlightText('~/.mimic/credentials')}`);
|
|
75
75
|
console.log();
|
|
76
|
-
console.log(`You can now deploy
|
|
76
|
+
console.log(`You can now deploy functions using: ${log_1.default.highlightText('mimic deploy')}`);
|
|
77
77
|
if (profileName !== CredentialsManager_1.CredentialsManager.getDefaultProfileName()) {
|
|
78
78
|
console.log(`Or with your profile: ${log_1.default.highlightText(`mimic deploy --profile ${profileName}`)}`);
|
|
79
79
|
}
|
package/dist/commands/test.js
CHANGED
|
@@ -54,10 +54,10 @@ class Test extends core_1.Command {
|
|
|
54
54
|
this.exit(result.status ?? 1);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
Test.description = 'Runs
|
|
57
|
+
Test.description = 'Runs function tests';
|
|
58
58
|
Test.examples = ['<%= config.bin %> <%= command.id %> --directory ./'];
|
|
59
59
|
Test.flags = {
|
|
60
|
-
directory: core_1.Flags.string({ char: 'd', description: '
|
|
60
|
+
directory: core_1.Flags.string({ char: 'd', description: 'function directory', default: './' }),
|
|
61
61
|
'skip-compile': core_1.Flags.boolean({ description: 'skip codegen and compile steps' }),
|
|
62
62
|
};
|
|
63
63
|
exports.default = Test;
|
|
@@ -17,7 +17,7 @@ exports.default = {
|
|
|
17
17
|
` ${inputsMapping}`,
|
|
18
18
|
'}',
|
|
19
19
|
'',
|
|
20
|
-
'// The class name is intentionally lowercase and plural to resemble a namespace when used in a
|
|
20
|
+
'// The class name is intentionally lowercase and plural to resemble a namespace when used in a function.',
|
|
21
21
|
'export class inputs {',
|
|
22
22
|
` ${inputsClass}`,
|
|
23
23
|
'}',
|