mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-17 15:57:21 +03:00
Simplify daml new template release process and add a simpler default template. (#850)
* Skeleton template. * Add quickstart-java template. * Update release rule * Add Main.daml in skeleton template. * Change default template for daml new. * Update templates/BUILD.bazel * Fix bazel rule formatting. * Update integration test to use quickstart-java template.
This commit is contained in:
parent
b081a8320f
commit
12e8baa93f
@ -39,7 +39,7 @@ commandParser =
|
||||
[ ListTemplates <$ flag' () (long "list" <> help "List the available project templates.")
|
||||
, New
|
||||
<$> argument str (metavar "TARGET_PATH" <> help "Path where the new project should be located")
|
||||
<*> argument str (metavar "TEMPLATE" <> help "Name of the template used to create the project (default: quickstart-java)" <> value "quickstart-java")
|
||||
<*> argument str (metavar "TEMPLATE" <> help "Name of the template used to create the project (default: skeleton)" <> value "skeleton")
|
||||
]
|
||||
startCmd = pure Start
|
||||
readReplacement :: ReadM ReplaceExtension
|
||||
|
@ -58,7 +58,7 @@ tests tmpDir = testGroup "Integration tests"
|
||||
quickstartTests :: FilePath -> FilePath -> TestTree
|
||||
quickstartTests quickstartDir mvnDir = testGroup "quickstart"
|
||||
[ testCase "daml new" $
|
||||
callProcessQuiet "daml" ["new", quickstartDir]
|
||||
callProcessQuiet "daml" ["new", quickstartDir, "quickstart-java"]
|
||||
, testCase "daml build " $ withCurrentDirectory quickstartDir $
|
||||
callProcessQuiet "daml" ["build", "-o", "target/daml/iou.dar"]
|
||||
, testCase "daml damlc test" $ withCurrentDirectory quickstartDir $
|
||||
|
@ -86,7 +86,7 @@ genrule(
|
||||
"//ledger/sandbox:sandbox-binary_deploy.jar",
|
||||
"//navigator/backend:navigator-binary_deploy.jar",
|
||||
"//extractor:extractor-binary_deploy.jar",
|
||||
"//docs:quickstart-java.tar.gz",
|
||||
"//templates:templates-tarball.tar.gz",
|
||||
],
|
||||
outs = ["sdk-release-tarball.tar.gz"],
|
||||
cmd = """
|
||||
@ -121,28 +121,8 @@ genrule(
|
||||
mkdir -p $$OUT/extractor
|
||||
cp $(location //extractor:extractor-binary_deploy.jar) $$OUT/extractor/extractor.jar
|
||||
|
||||
mkdir -p $$OUT/templates/quickstart-java
|
||||
tar xf $(location //docs:quickstart-java.tar.gz) --strip-components=1 -C $$OUT/templates/quickstart-java
|
||||
# While we use this template for both da-assistant and daml-assistant we do some manual patching here.
|
||||
# Once da-assistant is dead, the quickstart-java rule should produce the final version.
|
||||
rm $$OUT/templates/quickstart-java/da-skeleton.yaml
|
||||
cat > $$OUT/templates/quickstart-java/daml.yaml.template << EOF
|
||||
sdk-version: __VERSION__
|
||||
name: __PROJECT_NAME__
|
||||
source: daml/Main.daml
|
||||
scenario: Main:setup
|
||||
parties:
|
||||
- Alice
|
||||
- Bob
|
||||
- USD_Bank
|
||||
- EUR_Bank
|
||||
version: 1.0.0
|
||||
exposed-modules:
|
||||
- Main
|
||||
dependencies:
|
||||
- daml-prim
|
||||
- daml-stdlib
|
||||
EOF
|
||||
mkdir -p $$OUT/templates
|
||||
tar xf $(location //templates:templates-tarball.tar.gz) --strip-components=1 -C $$OUT/templates
|
||||
|
||||
tar zcf $(location sdk-release-tarball.tar.gz) --format=ustar $$OUT
|
||||
""",
|
||||
|
30
templates/BUILD.bazel
Normal file
30
templates/BUILD.bazel
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
genrule(
|
||||
name = "templates-tarball",
|
||||
srcs = glob([
|
||||
"skeleton/**",
|
||||
"quickstart-java/**",
|
||||
]) + ["//docs:quickstart-java.tar.gz"],
|
||||
outs = ["templates-tarball.tar.gz"],
|
||||
cmd = """
|
||||
SRC=templates
|
||||
OUT=templates-tarball
|
||||
|
||||
# skeleton template
|
||||
mkdir -p $$OUT/skeleton
|
||||
cp -rL $$SRC/skeleton/* $$OUT/skeleton/
|
||||
|
||||
# quickstart-java template
|
||||
# right now, uses the preexisting quickstart-java rule and replaces the da.yaml template with a daml.yaml template
|
||||
# in the future, move everything into //templates/quickstart-java and avoid untar, rm here
|
||||
mkdir -p $$OUT/quickstart-java
|
||||
tar xf $(location //docs:quickstart-java.tar.gz) --strip-components=1 -C $$OUT/quickstart-java
|
||||
rm $$OUT/quickstart-java/da-skeleton.yaml
|
||||
cp -rL $$SRC/quickstart-java/* $$OUT/quickstart-java/
|
||||
|
||||
tar zcf $(location :templates-tarball.tar.gz) templates-tarball
|
||||
""",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
15
templates/quickstart-java/daml.yaml.template
Normal file
15
templates/quickstart-java/daml.yaml.template
Normal file
@ -0,0 +1,15 @@
|
||||
sdk-version: __VERSION__
|
||||
name: __PROJECT_NAME__
|
||||
source: daml/Main.daml
|
||||
scenario: Main:setup
|
||||
parties:
|
||||
- Alice
|
||||
- Bob
|
||||
- USD_Bank
|
||||
- EUR_Bank
|
||||
version: 1.0.0
|
||||
exposed-modules:
|
||||
- Main
|
||||
dependencies:
|
||||
- daml-prim
|
||||
- daml-stdlib
|
13
templates/skeleton/daml.yaml.template
Normal file
13
templates/skeleton/daml.yaml.template
Normal file
@ -0,0 +1,13 @@
|
||||
sdk-version: __VERSION__
|
||||
name: __PROJECT_NAME__
|
||||
source: daml/Main.daml
|
||||
scenario: Main:setup
|
||||
parties:
|
||||
- Alice
|
||||
- Bob
|
||||
version: 1.0.0
|
||||
exposed-modules:
|
||||
- Main
|
||||
dependencies:
|
||||
- daml-prim
|
||||
- daml-stdlib
|
39
templates/skeleton/daml/Main.daml
Normal file
39
templates/skeleton/daml/Main.daml
Normal file
@ -0,0 +1,39 @@
|
||||
-- Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
daml 1.2
|
||||
module Main where
|
||||
|
||||
type AssetId = ContractId Asset
|
||||
|
||||
template Asset
|
||||
with
|
||||
issuer : Party
|
||||
owner : Party
|
||||
name : Text
|
||||
where
|
||||
ensure name /= ""
|
||||
signatory issuer
|
||||
controller owner can
|
||||
Give : AssetId
|
||||
with
|
||||
newOwner : Party
|
||||
do
|
||||
create this with
|
||||
owner = newOwner
|
||||
|
||||
setup = scenario do
|
||||
alice <- getParty "Alice"
|
||||
bob <- getParty "Bob"
|
||||
|
||||
aliceTV <- submit alice do
|
||||
create Asset with
|
||||
issuer = alice
|
||||
owner = alice
|
||||
name = "TV"
|
||||
|
||||
bobTV <- submit alice do
|
||||
exercise aliceTV Give with newOwner = bob
|
||||
|
||||
submit bob do
|
||||
exercise bobTV Give with newOwner = alice
|
Loading…
Reference in New Issue
Block a user