create-canton-app 1.1.0 → 1.4.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/README.md +3 -2
- package/package.json +1 -1
- package/src/commands/create.js +10 -33
- package/src/templates/token/daml/Tests.daml +0 -67
package/README.md
CHANGED
|
@@ -15,9 +15,11 @@ Scaffold Canton Network Daml projects in seconds. A CLI tool to quickly bootstra
|
|
|
15
15
|
### Create Your First Canton dApp
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npx create-canton-app
|
|
18
|
+
npx create-canton-app
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
> Follow the Instructions and select the desired template.
|
|
22
|
+
|
|
21
23
|
### Build and Test
|
|
22
24
|
|
|
23
25
|
```bash
|
|
@@ -71,7 +73,6 @@ choices: [
|
|
|
71
73
|
4. Try it
|
|
72
74
|
|
|
73
75
|
```bash
|
|
74
|
-
cd test-my-template
|
|
75
76
|
daml build
|
|
76
77
|
daml test
|
|
77
78
|
```
|
package/package.json
CHANGED
package/src/commands/create.js
CHANGED
|
@@ -14,12 +14,10 @@ const colors = {
|
|
|
14
14
|
bold: (text) => `\x1b[1m${text}\x1b[0m`
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
// Check if Daml SDK is installed
|
|
18
17
|
function isDamlInstalled() {
|
|
19
18
|
return shell.which('daml') !== null;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
// Get Daml version
|
|
23
21
|
function getDamlVersion() {
|
|
24
22
|
try {
|
|
25
23
|
const result = shell.exec('daml version', { silent: true });
|
|
@@ -30,7 +28,6 @@ function getDamlVersion() {
|
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
// Install Daml SDK automatically
|
|
34
31
|
async function installDamlSDK() {
|
|
35
32
|
console.log('');
|
|
36
33
|
console.log(colors.yellow('⚠️ Daml SDK not found!'));
|
|
@@ -60,23 +57,17 @@ async function installDamlSDK() {
|
|
|
60
57
|
const spinner = ora('Installing Daml SDK (this may take a few minutes)...').start();
|
|
61
58
|
|
|
62
59
|
try {
|
|
63
|
-
|
|
64
|
-
const result = shell.exec('curl -sSL https://get.daml.com/ | sh', {
|
|
65
|
-
silent: true
|
|
66
|
-
});
|
|
60
|
+
const result = shell.exec('curl -sSL https://get.daml.com/ | sh', { silent: true });
|
|
67
61
|
|
|
68
62
|
if (result.code !== 0) {
|
|
69
63
|
spinner.fail(colors.red('Failed to install Daml SDK'));
|
|
70
64
|
console.log('');
|
|
71
|
-
console.log(colors.red('Error:'), result.stderr);
|
|
72
|
-
console.log('');
|
|
73
65
|
console.log(colors.yellow('Please install manually:'));
|
|
74
66
|
console.log(colors.white(' curl -sSL https://get.daml.com/ | sh'));
|
|
75
67
|
console.log('');
|
|
76
68
|
return false;
|
|
77
69
|
}
|
|
78
70
|
|
|
79
|
-
// Add to PATH for current session
|
|
80
71
|
const damlPath = path.join(process.env.HOME, '.daml', 'bin');
|
|
81
72
|
process.env.PATH = `${damlPath}:${process.env.PATH}`;
|
|
82
73
|
|
|
@@ -88,9 +79,6 @@ async function installDamlSDK() {
|
|
|
88
79
|
console.log('');
|
|
89
80
|
console.log(colors.white(` export PATH="$HOME/.daml/bin:$PATH"`));
|
|
90
81
|
console.log('');
|
|
91
|
-
console.log(colors.dim('Then reload your shell:'));
|
|
92
|
-
console.log(colors.white(' source ~/.zshrc'));
|
|
93
|
-
console.log('');
|
|
94
82
|
|
|
95
83
|
return true;
|
|
96
84
|
} catch (error) {
|
|
@@ -101,17 +89,15 @@ async function installDamlSDK() {
|
|
|
101
89
|
|
|
102
90
|
async function create(projectName, options) {
|
|
103
91
|
try {
|
|
104
|
-
// Check prerequisites
|
|
92
|
+
// Check prerequisites
|
|
105
93
|
console.log('');
|
|
106
94
|
console.log(colors.cyan('🔍 Checking prerequisites...'));
|
|
107
95
|
console.log('');
|
|
108
96
|
|
|
109
|
-
// Check Daml SDK
|
|
110
97
|
if (!isDamlInstalled()) {
|
|
111
98
|
const installed = await installDamlSDK();
|
|
112
99
|
if (!installed) {
|
|
113
100
|
console.log(colors.yellow('⚠️ Continuing without Daml SDK...'));
|
|
114
|
-
console.log(colors.dim('You can still create the project, but won\'t be able to compile until Daml is installed.'));
|
|
115
101
|
console.log('');
|
|
116
102
|
}
|
|
117
103
|
} else {
|
|
@@ -119,7 +105,6 @@ async function create(projectName, options) {
|
|
|
119
105
|
console.log(colors.green(`✅ Daml SDK found${version ? ` (v${version})` : ''}`));
|
|
120
106
|
}
|
|
121
107
|
|
|
122
|
-
// Check Java (just informational)
|
|
123
108
|
if (!shell.which('java')) {
|
|
124
109
|
console.log(colors.yellow('⚠️ Java not found (optional, needed for tests)'));
|
|
125
110
|
} else {
|
|
@@ -128,7 +113,7 @@ async function create(projectName, options) {
|
|
|
128
113
|
|
|
129
114
|
console.log('');
|
|
130
115
|
|
|
131
|
-
//
|
|
116
|
+
// Get project name
|
|
132
117
|
if (!projectName) {
|
|
133
118
|
const answers = await inquirer.prompt([
|
|
134
119
|
{
|
|
@@ -141,8 +126,13 @@ async function create(projectName, options) {
|
|
|
141
126
|
projectName = answers.projectName;
|
|
142
127
|
}
|
|
143
128
|
|
|
129
|
+
// FIXED: Always ask for template if not explicitly provided via CLI flag
|
|
144
130
|
let template = options.template;
|
|
145
|
-
|
|
131
|
+
|
|
132
|
+
// Check if template was explicitly provided (not just the default)
|
|
133
|
+
const wasTemplateProvided = process.argv.includes('--template') || process.argv.includes('-t');
|
|
134
|
+
|
|
135
|
+
if (!wasTemplateProvided) {
|
|
146
136
|
const answers = await inquirer.prompt([
|
|
147
137
|
{
|
|
148
138
|
type: 'list',
|
|
@@ -188,7 +178,6 @@ async function create(projectName, options) {
|
|
|
188
178
|
|
|
189
179
|
spinner.succeed(colors.green('✨ Project created successfully!'));
|
|
190
180
|
|
|
191
|
-
// Show next steps
|
|
192
181
|
console.log('');
|
|
193
182
|
console.log(colors.cyan(colors.bold('📚 Next steps:')));
|
|
194
183
|
console.log('');
|
|
@@ -200,8 +189,6 @@ async function create(projectName, options) {
|
|
|
200
189
|
} else {
|
|
201
190
|
console.log(colors.yellow(` # First, install Daml SDK:`));
|
|
202
191
|
console.log(colors.white(` curl -sSL https://get.daml.com/ | sh`));
|
|
203
|
-
console.log(colors.white(` source ~/.zshrc`));
|
|
204
|
-
console.log(colors.white(` daml build`));
|
|
205
192
|
}
|
|
206
193
|
|
|
207
194
|
console.log('');
|
|
@@ -272,16 +259,6 @@ daml build
|
|
|
272
259
|
daml test
|
|
273
260
|
\`\`\`
|
|
274
261
|
|
|
275
|
-
## Prerequisites
|
|
276
|
-
|
|
277
|
-
If you don't have Daml SDK installed, the CLI will offer to install it automatically.
|
|
278
|
-
|
|
279
|
-
Or install manually:
|
|
280
|
-
|
|
281
|
-
\`\`\`bash
|
|
282
|
-
curl -sSL https://get.daml.com/ | sh
|
|
283
|
-
\`\`\`
|
|
284
|
-
|
|
285
262
|
## Learn More
|
|
286
263
|
|
|
287
264
|
- [Canton Docs](https://docs.digitalasset.com)
|
|
@@ -292,4 +269,4 @@ curl -sSL https://get.daml.com/ | sh
|
|
|
292
269
|
fs.writeFileSync(path.join(projectPath, 'README.md'), readme);
|
|
293
270
|
}
|
|
294
271
|
|
|
295
|
-
module.exports = create;
|
|
272
|
+
module.exports = create;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
-- Tests.daml
|
|
2
|
-
-- Test suite for the Token contract
|
|
3
|
-
|
|
4
|
-
module Tests where
|
|
5
|
-
|
|
6
|
-
import Daml.Script
|
|
7
|
-
import Token
|
|
8
|
-
|
|
9
|
-
-- Test: Token creation
|
|
10
|
-
testTokenCreation : Script ()
|
|
11
|
-
testTokenCreation = script do
|
|
12
|
-
alice <- allocateParty "Alice"
|
|
13
|
-
issuer <- allocateParty "Issuer"
|
|
14
|
-
|
|
15
|
-
token <- submit issuer do
|
|
16
|
-
createCmd Token with
|
|
17
|
-
issuer = issuer
|
|
18
|
-
owner = alice
|
|
19
|
-
amount = 100.0
|
|
20
|
-
symbol = "TEST"
|
|
21
|
-
|
|
22
|
-
Some tokenData <- queryContractId alice token
|
|
23
|
-
assert (tokenData.amount == 100.0)
|
|
24
|
-
assert (tokenData.symbol == "TEST")
|
|
25
|
-
|
|
26
|
-
-- Test: Token transfer
|
|
27
|
-
testTokenTransfer : Script ()
|
|
28
|
-
testTokenTransfer = script do
|
|
29
|
-
alice <- allocateParty "Alice"
|
|
30
|
-
bob <- allocateParty "Bob"
|
|
31
|
-
issuer <- allocateParty "Issuer"
|
|
32
|
-
|
|
33
|
-
token <- submit issuer do
|
|
34
|
-
createCmd Token with
|
|
35
|
-
issuer = issuer
|
|
36
|
-
owner = alice
|
|
37
|
-
amount = 50.0
|
|
38
|
-
symbol = "TEST"
|
|
39
|
-
|
|
40
|
-
newToken <- submit alice do
|
|
41
|
-
exerciseCmd token Transfer with newOwner = bob
|
|
42
|
-
|
|
43
|
-
Some tokenData <- queryContractId bob newToken
|
|
44
|
-
assert (tokenData.owner == bob)
|
|
45
|
-
assert (tokenData.amount == 50.0)
|
|
46
|
-
|
|
47
|
-
-- Test: Token split
|
|
48
|
-
testTokenSplit : Script ()
|
|
49
|
-
testTokenSplit = script do
|
|
50
|
-
alice <- allocateParty "Alice"
|
|
51
|
-
issuer <- allocateParty "Issuer"
|
|
52
|
-
|
|
53
|
-
token <- submit issuer do
|
|
54
|
-
createCmd Token with
|
|
55
|
-
issuer = issuer
|
|
56
|
-
owner = alice
|
|
57
|
-
amount = 100.0
|
|
58
|
-
symbol = "TEST"
|
|
59
|
-
|
|
60
|
-
(token1, token2) <- submit alice do
|
|
61
|
-
exerciseCmd token Split with splitAmount = 30.0
|
|
62
|
-
|
|
63
|
-
Some data1 <- queryContractId alice token1
|
|
64
|
-
Some data2 <- queryContractId alice token2
|
|
65
|
-
|
|
66
|
-
assert (data1.amount == 30.0)
|
|
67
|
-
assert (data2.amount == 70.0)
|