Rename daml2ts to daml2js (#5394)

This is pretty much a search and replace over the whole repo, including
file names.

CHANGELOG_BEGIN
CHANGELOG_END
This commit is contained in:
Martin Huschenbett 2020-04-03 08:58:23 +02:00 committed by GitHub
parent 446892a80e
commit 31c78d57d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 118 additions and 118 deletions

10
BUILD
View File

@ -199,13 +199,13 @@ alias(
)
alias(
name = "daml2ts",
actual = "//language-support/ts/codegen:daml2ts",
name = "daml2js",
actual = "//language-support/ts/codegen:daml2js",
)
alias(
name = "daml2ts@ghci",
actual = "//language-support/ts/codegen:daml2ts@ghci",
name = "daml2js@ghci",
actual = "//language-support/ts/codegen:daml2js@ghci",
)
alias(
@ -282,6 +282,6 @@ da_haskell_repl(
"//daml-assistant/integration-tests",
"//language-support/hs/bindings:hs-ledger",
"//language-support/hs/bindings:test",
"//language-support/ts/codegen:daml2ts",
"//language-support/ts/codegen:daml2js",
],
)

View File

@ -346,7 +346,7 @@ runCommand = \case
Codegen {..} ->
case lang of
TypeScript ->
runDaml2ts remainingArguments
runDaml2js remainingArguments
Java ->
runJar
"daml-sdk/daml-sdk.jar"

View File

@ -6,7 +6,7 @@ module DA.Daml.Helper.Run
, runInit
, runNew
, runJar
, runDaml2ts
, runDaml2js
, runListTemplates
, runStart
@ -325,11 +325,11 @@ runJar jarPath mbLogbackPath remainingArgs = do
mbLogbackArg <- traverse getLogbackArg mbLogbackPath
withJar jarPath (toList mbLogbackArg) remainingArgs (const $ pure ())
runDaml2ts :: [String] -> IO ()
runDaml2ts remainingArgs = do
daml2ts <- fmap (</> "daml2ts" </> "daml2ts") getSdkPath
withProcessWait_' (proc daml2ts remainingArgs) (const $ pure ()) `catchIO`
(\e -> hPutStrLn stderr "Failed to invoke daml2ts." *> throwIO e)
runDaml2js :: [String] -> IO ()
runDaml2js remainingArgs = do
daml2js <- fmap (</> "daml2js" </> "daml2js") getSdkPath
withProcessWait_' (proc daml2js remainingArgs) (const $ pure ()) `catchIO`
(\e -> hPutStrLn stderr "Failed to invoke daml2js." *> throwIO e)
getLogbackArg :: FilePath -> IO String
getLogbackArg relPath = do

View File

@ -130,7 +130,7 @@ da_haskell_test(
"//:sdk-version-hs-lib",
"//compiler/damlc/daml-opts:daml-opts-types",
"//daml-assistant/daml-helper:daml-helper-lib",
"//language-support/ts/codegen/tests:daml2ts-test-helpers",
"//language-support/ts/codegen/tests:daml2js-test-helpers",
"//libs-haskell/bazel-runfiles",
"//libs-haskell/da-hs-base",
"//libs-haskell/test-utils",

View File

@ -38,7 +38,7 @@ import DA.Directory
import DA.Bazel.Runfiles
import DA.Daml.Assistant.FreePort (getFreePort,socketHints)
import DA.Daml.Helper.Run (waitForHttpServer,waitForConnectionOnPort)
import DA.Test.Daml2TsUtils (writeRootPackageJson)
import DA.Test.Daml2jsUtils (writeRootPackageJson)
import DA.Test.Process (callCommandSilent,callProcessSilent)
import DA.Test.Util
import SdkVersion
@ -524,7 +524,7 @@ codegenTests codegenDir damlTypes = testGroup "daml codegen" (
, codegenTestFor "scala" (Just "com.cookiemonster.nomnomnom")
] ++
-- The 'daml-types' NPM package is not available on Windows which
-- is required by 'daml2ts'.
-- is required by 'daml2js'.
[ codegenTestFor "ts" Nothing | not isWindows ]
)
where

View File

@ -101,7 +101,7 @@ Experimental features
triggers/index
daml-repl/index
tools/visual
daml2ts/index
daml2js/index
getting-started/index
getting-started/testing

View File

@ -63,7 +63,7 @@ JSON <json-api>` endpoints. In addition, we provide support libraries for :ref:`
.. TODO (drsk) add and point to javascript bindings.
.. If you choose a different Javascript based frontend framework, the packages ``@daml/ledger``,
.. ``@daml/types`` and the generated ``@daml2ts`` package provide you with the necessary interface code
.. ``@daml/types`` and the generated ``@daml2js`` package provide you with the necessary interface code
.. to connect and issue commands against your ledger.
We provide two libraries to build your React frontend for a DAML application.

View File

@ -1,25 +1,25 @@
.. Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
.. SPDX-License-Identifier: Apache-2.0
``daml2ts`` - TypeScript code generator for DAML
``daml2js`` - TypeScript code generator for DAML
################################################
daml2ts : TypeScript of DAML
daml2js : TypeScript of DAML
============================
Introduction
------------
``daml2ts`` generates TypeScript for interacting with DAML via the `json-api <../json-api/index.html>`_ .
``daml2js`` generates TypeScript for interacting with DAML via the `json-api <../json-api/index.html>`_ .
``daml2ts`` inputs are compiled DAML modules. ``daml2ts`` outputs are TypeScript source files containing definitions modeling the DAML entities found.
``daml2js`` inputs are compiled DAML modules. ``daml2js`` outputs are TypeScript source files containing definitions modeling the DAML entities found.
The code ``daml2ts`` generates uses the library `@daml/types <https://github.com/digital-asset/daml/tree/master/language-support/ts/daml-types>`_.
The code ``daml2js`` generates uses the library `@daml/types <https://github.com/digital-asset/daml/tree/master/language-support/ts/daml-types>`_.
Usage
-----
``daml2ts`` is invoked via the DAML SDK assistant.
``daml2js`` is invoked via the DAML SDK assistant.
In outline, the command to generate JavaScript and TypeScript typings from DAML is ``daml codegen ts DAR -o OUTDIR`` where ``DAR`` is the path to a DAR file (generated via ``daml build``) and ``OUTDIR`` is a directory where you want the JavaScript to be written.
@ -31,11 +31,11 @@ Here's a complete example that generates TypeScript from a project produced from
daml new my-proj skeleton # Create a new project based off the skeleton template
cd my-proj # Enter the newly created project directory
daml build # Compile the project's DAML files into a DAR
daml codegen ts .daml/dist/my-proj-0.0.1.dar -o daml2ts # Generate script bindings from the DAR
daml codegen ts .daml/dist/my-proj-0.0.1.dar -o daml2js # Generate script bindings from the DAR
- On execution of these commands:
- The directory ``my-proj/daml2ts`` contains generated TypeScript and Javascript artifacts;
- The directory ``my-proj/daml2js`` contains generated TypeScript and Javascript artifacts;
- The files are arranged into directories;
- One of those directories will be named as my-proj-0.0.1 and will contain the definitions corresponding to the DAML files in the project;
- For example, ``generated/ts/my-proj/src/Main.ts`` contains the definitions for ``daml/Main.daml``;
@ -47,7 +47,7 @@ To get a quickstart idea of how to use what has been generated, you may wish to
Primitive DAML types: @daml/types
---------------------------------
To understand the TypeScript code generated by ``daml2ts``, it is helpful to keep in mind this quick review of the TypeScript equivalents of the primitive DAML types provided by @daml/types.
To understand the TypeScript code generated by ``daml2js``, it is helpful to keep in mind this quick review of the TypeScript equivalents of the primitive DAML types provided by @daml/types.
**Interfaces**:
@ -233,7 +233,7 @@ Here is a DAML template of a basic 'IOU' contract.
do
create this with owner = newOwner
``daml2ts`` generates types for each of the choices defined on the template as well as the template itself.
``daml2js`` generates types for each of the choices defined on the template as well as the template itself.
.. code-block:: typescript
:linenos:

View File

@ -104,7 +104,7 @@ DAML SDK documentation
DAML Triggers <triggers/index>
DAML Repl <daml-repl/index>
tools/visual
daml2ts/index
daml2js/index
getting-started/index
getting-started/testing

View File

@ -5,7 +5,7 @@ load("//bazel_tools:haskell.bzl", "da_haskell_binary")
load("//bazel_tools/packaging:packaging.bzl", "package_app")
da_haskell_binary(
name = "daml2ts",
name = "daml2js",
srcs = glob(["src/**/*.hs"]),
hackage_deps = [
"aeson",
@ -37,7 +37,7 @@ da_haskell_binary(
)
package_app(
name = "daml2ts-dist",
binary = ":daml2ts",
name = "daml2js-dist",
binary = ":daml2js",
visibility = ["//visibility:public"],
)

View File

@ -1,13 +1,13 @@
# daml2ts
# daml2js
This is a code generator for a TypeScript interface to a DAML package. To run it, you must execute
```console
$ bazel run //:daml2ts
Usage: daml2ts DAR-FILE -o DIR
$ bazel run //:daml2js
Usage: daml2js DAR-FILE -o DIR
Generate TypeScript bindings from a DAR
```
somewhere in this repository. The `DAR-FILE` is the DAR for which you want to
generate the TypeScript interface. `daml2ts` will generate interfaces for
generate the TypeScript interface. `daml2js` will generate interfaces for
all DALFs in that DAR. The output will be written into the directory `DIR`
you specify via the `-o` option.
@ -15,7 +15,7 @@ Currently, the generated interfaces are tailored towards the
[`ledger.ts`](https://github.com/digital-asset/davl/blob/master/ui/src/ledger/ledger.ts)
module of DAVL.
## How to develop daml2ts
## How to develop daml2js
The full test suite is started via
```
@ -27,11 +27,11 @@ development. To make things more responsive, you can run the following
trinity of shell scripts, all in parallel and each in its own terminal:
- `./tests/watch-damlc.sh`: Build a DAR out of the `.daml` files in
`./tests/daml` whenever they change.
- `./tests/watch-daml2ts.sh`: Re-interpret `daml2ts` and run it on the DAR
- `./tests/watch-daml2js.sh`: Re-interpret `daml2js` and run it on the DAR
produced by `./tests/watch-damlc.sh`.
- `./tests/watch-yarn`: Build all the TypeScript libraries in dependency
order and run the TypeScript compiler in watch mode on the TypeScript
generated by `./tests/watch-daml2ts.sh`. This script does not recompile
generated by `./tests/watch-daml2js.sh`. This script does not recompile
any changes made to the TypeScript libraries `@daml/types` or
`@daml/ledger`. Changes to these libraries must be manually
recompiled using `yarn build` in the respective directories. (You can also
@ -40,10 +40,10 @@ trinity of shell scripts, all in parallel and each in its own terminal:
All these steps only check that everything compiles. They do _not_ run any
tests. To run the tests suite, you need to issue the command above.
### How to run daml2ts on a set of DARs from bazel
### How to run daml2js on a set of DARs from bazel
Running the code-generator outside of the SDK means having to take
into account the dependency of daml2ts generated packages on a version
into account the dependency of daml2js generated packages on a version
of `daml-types` that is not available on NPM. The folllowing recipe
shows how it's done (obviously you'll need to adapt paths in the below
to your own environment).
@ -53,7 +53,7 @@ cd ~/tmp/davl
cat > package.json<<EOF
{
"private": true,
"workspaces": ["daml2ts"],
"workspaces": ["daml2js"],
"resolutions": {
"@daml/types": "file:daml-types"
}
@ -62,12 +62,12 @@ EOF
cd ~/project/daml.git
bazel build //language-support/ts/daml-types:npm_package
cp -R bazel-bin/language-support/ts/daml-types/npm_package ~/tmp/davl/daml-types
bazel run //language-support/ts/codegen:daml2ts -- -o ~/tmp/davl/daml2ts ~/project/davl.git/released/*.dar
bazel run //language-support/ts/codegen:daml2js -- -o ~/tmp/davl/daml2js ~/project/davl.git/released/*.dar
```
## What `daml2ts` generates
## What `daml2js` generates
The DAML SDK documentation contains [a page](https://github.com/digital-asset/daml/tree/master/docs/source/daml2ts) on `daml2ts`. It is recommended that you start with this. The remainder of this section contains additional detail (mostly about serialization code). The code that `daml2ts` generates uses the [@daml/types](https://github.com/digital-asset/daml/tree/master/language-support/ts/daml-types) and [@mojotech/json-type-validation](https://github.com/mojotech/json-type-validation) libraries. All TypeScript modules generated by `daml2ts` begin with the following fragment:
The DAML SDK documentation contains [a page](https://github.com/digital-asset/daml/tree/master/docs/source/daml2js) on `daml2js`. It is recommended that you start with this. The remainder of this section contains additional detail (mostly about serialization code). The code that `daml2js` generates uses the [@daml/types](https://github.com/digital-asset/daml/tree/master/language-support/ts/daml-types) and [@mojotech/json-type-validation](https://github.com/mojotech/json-type-validation) libraries. All TypeScript modules generated by `daml2js` begin with the following fragment:
```typescript
import * as jtv from '@mojotech/json-type-validation';
import * as daml from '@daml/types';
@ -78,7 +78,7 @@ import * as daml from '@daml/types';
#### Types
See the [SDK docs](https://github.com/digital-asset/daml/tree/master/docs/source/daml2ts).
See the [SDK docs](https://github.com/digital-asset/daml/tree/master/docs/source/daml2js).
#### Interfaces
@ -220,7 +220,7 @@ A DAML enumeration.
data Color = Red | Blue | Yellow
```
In TypeScript, `daml2ts` produces this.
In TypeScript, `daml2js` produces this.
```typescript
export enum Color {
@ -315,7 +315,7 @@ export namespace Iou {
daml.registerTemplate(Iou);
```
`daml2ts` has produced:
`daml2js` has produced:
- Type definitions corresponding to the `Transfer` choice and the `Iou` template;
- Companion objects for those types;
- An `Iou` template associated type definition `Key` in the `Iou` namespace;

View File

@ -146,7 +146,7 @@ main = do
Nothing -> id
Just pkgName -> unPackageName pkgName <> " (hash: " <> id <> ")"
T.putStrLn $ "Generating " <> pkgDesc
daml2ts Daml2TsParams{..}
daml2js Daml2jsParams{..}
buildPackages sdkVersion optScope optOutputDir dependencies
packageNameText :: PackageId -> Maybe PackageName -> T.Text
@ -155,7 +155,7 @@ packageNameText pkgId mbPkgIdent = maybe (unPackageId pkgId) unPackageName mbPkg
newtype Scope = Scope {unScope :: T.Text}
newtype Dependency = Dependency {unDependency :: T.Text} deriving (Eq, Ord)
data Daml2TsParams = Daml2TsParams
data Daml2jsParams = Daml2jsParams
{ opts :: Options -- cli args
, pkgMap :: Map.Map PackageId (Maybe PackageName, Package)
, pkgId :: PackageId
@ -165,15 +165,15 @@ data Daml2TsParams = Daml2TsParams
}
-- Write the files for a single package.
daml2ts :: Daml2TsParams -> IO (T.Text, [Dependency])
daml2ts Daml2TsParams {..} = do
daml2js :: Daml2jsParams -> IO (T.Text, [Dependency])
daml2js Daml2jsParams {..} = do
let Options {..} = opts
scopeDir = optOutputDir
-- The directory into which we generate packages e.g. '/path/to/daml2ts'.
-- The directory into which we generate packages e.g. '/path/to/daml2js'.
packageDir = scopeDir </> T.unpack pkgName
-- The directory into which we write this package e.g. '/path/to/daml2ts/davl-0.0.4'.
-- The directory into which we write this package e.g. '/path/to/daml2js/davl-0.0.4'.
packageSrcDir = packageDir </> "src"
-- Where the source files of this package are written e.g. '/path/to/daml2ts/davl-0.0.4/src'.
-- Where the source files of this package are written e.g. '/path/to/daml2js/davl-0.0.4/src'.
scope = optScope
-- The scope e.g. '@daml.js'.
-- We use this, for example, when generating import declarations e.g.
@ -564,7 +564,7 @@ writePackageJson packageDir sdkVersion (Scope scope) depends =
, "version" .= versionToText sdkVersion
, "main" .= ("lib/index.js" :: T.Text)
, "types" .= ("lib/index.d.ts" :: T.Text)
, "description" .= ("Generated by daml2ts" :: T.Text)
, "description" .= ("Generated by daml2js" :: T.Text)
, "dependencies" .= object
[ pkg .= path
| Dependency pkgName <- depends
@ -590,7 +590,7 @@ buildPackages sdkVersion optScope optOutputDir dependencies = do
where
packageJson :: Value
packageJson = object
[ "name" .= ("daml2ts" :: T.Text)
[ "name" .= ("daml2js" :: T.Text)
, "version" .= version
, "dependencies" .= object
[ "@mojotech/json-type-validation" .= jtvVersion

View File

@ -19,8 +19,8 @@ daml_compile(
# ==============
#
# 'build-and-lint.sh' is an integration test. It builds a DAR from
# some DAML, invokes daml2ts on the DAR, uploads the DAR to a ledger
# and then runs tests on the TypeScript generated by daml2ts via a
# some DAML, invokes daml2js on the DAR, uploads the DAR to a ledger
# and then runs tests on the TypeScript generated by daml2js via a
# json-api connected to the ledger.
#
# The main inputs to 'build-and-lint' are:
@ -34,7 +34,7 @@ daml_compile(
# 'build-and-lint-test' which houses the test driver 'test.ts'.
#
# 'build-and-lint' creates a temp directory ('root' say), and uses the
# above inputs (via filesystem copies, damlc, daml2ts and yarn install)
# above inputs (via filesystem copies, damlc, daml2js and yarn install)
# to produce a filesystem with the following structure:
#
# root/
@ -42,7 +42,7 @@ daml_compile(
# src/
# __tests__/
# test.ts
# daml2ts/
# daml2js/
# build-and-lint-1.0.0/ -- The artifacts generated of 'build-and-lint-1.0.0.dar'
# 057eed/
# ...
@ -54,8 +54,8 @@ daml_compile(
# ...
#
# In more detail, the actions of 'build-and-lint' are to:
# - Invoke 'daml2ts' on 'build-and-lint-1.0.0.dar' to produce bindings
# (in the 'daml2ts' directory);
# - Invoke 'daml2js' on 'build-and-lint-1.0.0.dar' to produce bindings
# (in the 'daml2js' directory);
# - Invoke from 'root':
# - 'yarn workspaces run install';
# - 'yarn workspaces run build';
@ -76,7 +76,7 @@ sh_test(
args = [
"$(location //:java)",
"$(location //:yarn)",
"$(location //:daml2ts)",
"$(location //:daml2js)",
"$(location //ledger/sandbox:sandbox-binary_deploy.jar)",
"$(location //ledger-service/http-json:http-json-binary_deploy.jar)",
"$(location :build-and-lint.dar)",
@ -88,7 +88,7 @@ sh_test(
data = [
"//:java",
"//:yarn",
"//:daml2ts",
"//:daml2js",
"//ledger/sandbox:sandbox-binary_deploy.jar",
"//ledger-service/http-json:http-json-binary_deploy.jar",
":build-and-lint.dar",
@ -110,8 +110,8 @@ sh_test(
) if is_linux else None
da_haskell_library(
name = "daml2ts-test-helpers",
srcs = ["src/DA/Test/Daml2TsUtils.hs"],
name = "daml2js-test-helpers",
srcs = ["src/DA/Test/Daml2jsUtils.hs"],
hackage_deps = [
"aeson",
"base",
@ -128,7 +128,7 @@ da_haskell_library(
],
)
# daml2ts
# daml2js
# =======
#
# This target is a unit-test. It does similar things to 'build-and-test'
@ -136,9 +136,9 @@ da_haskell_library(
# up ledgers and/or executing any TypeScript.
da_haskell_test(
name = "daml2ts",
name = "daml2js",
size = "large",
srcs = ["src/DA/Test/Daml2Ts.hs"],
srcs = ["src/DA/Test/Daml2js.hs"],
args = [
"$(location //:yarn)",
"$(location //language-support/ts/daml-types:npm_package)",
@ -146,7 +146,7 @@ da_haskell_test(
data = [
"//:yarn",
"//compiler/damlc",
"//language-support/ts/codegen:daml2ts",
"//language-support/ts/codegen:daml2js",
"//language-support/ts/daml-types:npm_package",
"@davl//:released/davl-upgrade-v4-v5.dar",
"@davl//:released/davl-v4.dar",
@ -165,11 +165,11 @@ da_haskell_test(
"text",
"unordered-containers",
],
main_function = "DA.Test.Daml2Ts.main",
main_function = "DA.Test.Daml2js.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
":daml2ts-test-helpers",
":daml2js-test-helpers",
"//compiler/daml-lf-ast",
"//libs-haskell/bazel-runfiles",
"//libs-haskell/da-hs-base",

View File

@ -58,10 +58,10 @@ cp -rL $DAML_LEDGER/* $TMP_DAML_LEDGER
cd $TMP_DIR
# Call daml2ts.
PATH=`dirname $YARN`:$PATH $DAML2TS -o daml2ts $DAR
# Call daml2js.
PATH=`dirname $YARN`:$PATH $DAML2TS -o daml2js $DAR
# We only needed this package.json in order to provide resolution of
# daml-types to daml2ts and that's done with now.
# daml-types to daml2js and that's done with now.
rm package.json
# Since we eschew using workspaces and resolutions in this test, patch
# up the daml-ledger dependency on daml-types.

View File

@ -1,7 +1,7 @@
-- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
{-# LANGUAGE DerivingStrategies #-}
module DA.Test.Daml2Ts (main) where
module DA.Test.Daml2js (main) where
import System.FilePath
import System.IO.Extra
@ -12,7 +12,7 @@ import System.Exit
import DA.Bazel.Runfiles
import qualified DA.Daml.LF.Ast.Version as LF
import DA.Directory
import DA.Test.Daml2TsUtils
import DA.Test.Daml2jsUtils
import Data.List.Extra
import qualified Data.Text.Extended as T
import qualified Data.ByteString.Lazy as BSL
@ -34,7 +34,7 @@ main :: IO ()
main = do
yarnPath : damlTypesPath : args <- getArgs
damlc <- locateRunfiles (mainWorkspace </> "compiler" </> "damlc" </> exe "damlc")
daml2ts <- locateRunfiles (mainWorkspace </> "language-support" </> "ts" </> "codegen" </> exe "daml2ts")
daml2js <- locateRunfiles (mainWorkspace </> "language-support" </> "ts" </> "codegen" </> exe "daml2js")
yarn <- locateRunfiles (mainWorkspace </> yarnPath)
damlTypes <- locateRunfiles (mainWorkspace </> damlTypesPath)
davl <- locateRunfiles ("davl" </> "released")
@ -42,7 +42,7 @@ main = do
withArgs args $ withEnv
[ ("PATH", Just $ intercalate [searchPathSeparator] $ takeDirectory yarn : oldPath)
, ("TASTY_NUM_THREADS", Just "1")
] $ defaultMain (tests damlTypes yarn damlc daml2ts davl)
] $ defaultMain (tests damlTypes yarn damlc daml2js davl)
-- It may help to keep in mind for the following tests, this quick
-- refresher on the layout of a simple project:
@ -52,7 +52,7 @@ main = do
-- daml/
-- Grover.daml
-- package.json
-- daml2ts/
-- daml2js/
-- grover-1.0/
-- package.json
-- tsconfig.json
@ -70,12 +70,12 @@ main = do
-- daml-types <-- referred to by the "resolutions" field in package.json
tests :: FilePath -> FilePath -> FilePath -> FilePath -> FilePath -> TestTree
tests damlTypes yarn damlc daml2ts davl = testGroup "daml2ts tests"
tests damlTypes yarn damlc daml2js davl = testGroup "daml2js tests"
[
testCaseSteps "Different package, same name test" $ \step -> withTempDir $ \here -> do
let grover = here </> "grover"
groverDaml = grover </> "daml"
daml2tsDir = here </> "daml2ts"
daml2jsDir = here </> "daml2js"
groverDar = grover </> ".daml" </> "dist" </> "grover-1.0.dar"
createDirectoryIfMissing True groverDaml
withCurrentDirectory grover $ do
@ -93,14 +93,14 @@ tests damlTypes yarn damlc daml2ts davl = testGroup "daml2ts tests"
writeDamlYaml "grover" ["Elmo"] ["daml-prim", "daml-stdlib"] Nothing
step "daml build..."
buildProject ["-o", ".daml" </> "dist" </> "elmo-1.0.dar"]
step "daml2ts..."
step "daml2js..."
setupYarnEnvironment
(exitCode, _, err) <- readProcessWithExitCode daml2ts ([groverDar, elmoDar] ++ ["-o", daml2tsDir]) ""
assertBool "daml2ts is expected to fail but succeeded" (exitCode /= ExitSuccess)
(exitCode, _, err) <- readProcessWithExitCode daml2js ([groverDar, elmoDar] ++ ["-o", daml2jsDir]) ""
assertBool "daml2js is expected to fail but succeeded" (exitCode /= ExitSuccess)
assertInfixOf "Duplicate name 'grover-1.0' for different packages detected" err
, testCaseSteps "Different name, same package test" $ \step -> withTempDir $ \here -> do
let daml2tsDir = here </> "daml2ts"
let daml2jsDir = here </> "daml2js"
let grover = here </> "grover"
groverDaml = grover </> "daml"
groverDar = grover </> ".daml" </> "dist" </> "grover-1.0.dar"
@ -124,17 +124,17 @@ tests damlTypes yarn damlc daml2ts davl = testGroup "daml2ts tests"
step "daml build..."
buildProject []
withCurrentDirectory here $ do
step "daml2ts..."
step "daml2js..."
setupYarnEnvironment
(exitCode, _, err) <- readProcessWithExitCode daml2ts ([groverDar, superGroverDar] ++ ["-o", daml2tsDir]) ""
assertBool "daml2ts is expected to fail but succeeded" (exitCode /= ExitSuccess)
(exitCode, _, err) <- readProcessWithExitCode daml2js ([groverDar, superGroverDar] ++ ["-o", daml2jsDir]) ""
assertBool "daml2js is expected to fail but succeeded" (exitCode /= ExitSuccess)
assertInfixOf "Different names ('grover-1.0' and 'super-grover-1.0') for the same package detected" err
, testCaseSteps "Same package, same name test" $ \step -> withTempDir $ \here -> do
let grover = here </> "grover"
groverDaml = grover </> "daml"
daml2tsDir = here </> "daml2ts"
groverTs = daml2tsDir </> "grover-1.0"
daml2jsDir = here </> "daml2js"
groverTs = daml2jsDir </> "grover-1.0"
groverDar = grover </> ".daml" </> "dist" </> "grover-1.0.dar"
createDirectoryIfMissing True groverDaml
withCurrentDirectory grover $ do
@ -144,15 +144,15 @@ tests damlTypes yarn damlc daml2ts davl = testGroup "daml2ts tests"
step "daml build..."
buildProject []
withCurrentDirectory here $ do
step "daml2ts..."
step "daml2js..."
setupYarnEnvironment
daml2tsProject [groverDar, groverDar] daml2tsDir
daml2jsProject [groverDar, groverDar] daml2jsDir
mapM_ (assertTsFileExists groverTs) [ "index", "Grover" </> "index", "Grover" </> "module" ]
, testCaseSteps "IndexTree test" $ \step -> withTempDir $ \here -> do
let projectRoot = here </> "project"
daml2tsDir = here </> "daml2ts"
projectTs = daml2tsDir </> "project-1.0"
daml2jsDir = here </> "daml2js"
projectTs = daml2jsDir </> "project-1.0"
projectDar = projectRoot </> ".daml" </> "dist" </> "project-1.0.dar"
createDirectoryIfMissing True projectRoot
withCurrentDirectory projectRoot $ do
@ -164,9 +164,9 @@ tests damlTypes yarn damlc daml2ts davl = testGroup "daml2ts tests"
step "daml build..."
buildProject []
withCurrentDirectory here $ do
step "daml2ts..."
step "daml2js..."
setupYarnEnvironment
daml2tsProject [projectDar] daml2tsDir
daml2jsProject [projectDar] daml2jsDir
mapM_ (assertTsFileExists projectTs)
[ "index"
, "A" </> "index"
@ -193,34 +193,34 @@ tests damlTypes yarn damlc daml2ts davl = testGroup "daml2ts tests"
assertFileLines ("A" </> "B" </> "D" </> "index.ts") reexportModule
, testCaseSteps "DAVL test" $ \step -> withTempDir $ \here -> do
let daml2tsDir = here </> "daml2ts"
let daml2jsDir = here </> "daml2js"
withCurrentDirectory here $ do
step "daml2ts..."
step "daml2js..."
setupYarnEnvironment
callProcessSilent daml2ts $
callProcessSilent daml2js $
[ davl </> "davl-v4.dar"
, davl </> "davl-v5.dar"
, davl </> "davl-upgrade-v4-v5.dar" ] ++
["-o", daml2tsDir]
mapM_ (assertTsFileExists (daml2tsDir </> "davl-0.0.4"))
["-o", daml2jsDir]
mapM_ (assertTsFileExists (daml2jsDir </> "davl-0.0.4"))
[ "index"
, "DAVL" </> "index"
, "DAVL" </> "module"
]
mapM_ (assertTsFileExists (daml2tsDir </> "davl-0.0.5"))
mapM_ (assertTsFileExists (daml2jsDir </> "davl-0.0.5"))
[ "index"
, "DAVL" </> "index"
, "DAVL" </> "V5" </> "index"
, "DAVL" </> "V5" </> "module"
]
mapM_ (assertTsFileExists (daml2tsDir </> "davl-upgrade-v4-v5-0.0.5"))
mapM_ (assertTsFileExists (daml2jsDir </> "davl-upgrade-v4-v5-0.0.5"))
[ "index"
, "Upgrade" </> "index"
, "Upgrade" </> "module"
]
step "eslint..."
withCurrentDirectory daml2tsDir $ do
pkgs <- (\\ ["package.json", "node_modules"]) <$> listDirectory daml2tsDir
withCurrentDirectory daml2jsDir $ do
pkgs <- (\\ ["package.json", "node_modules"]) <$> listDirectory daml2jsDir
BSL.writeFile "package.json" $ encode $
object
[ "private" .= True
@ -230,7 +230,7 @@ tests damlTypes yarn damlc daml2ts davl = testGroup "daml2ts tests"
, "@typescript-eslint/parser" .= typescriptEslintVersion
]
, "workspaces" .= pkgs
, "name" .= ("daml2ts" :: T.Text)
, "name" .= ("daml2js" :: T.Text)
, "version" .= ("0.0.0" :: T.Text)
]
BSL.writeFile ".eslintrc.json" $ encode $
@ -256,13 +256,13 @@ tests damlTypes yarn damlc daml2ts davl = testGroup "daml2ts tests"
setupYarnEnvironment :: IO ()
setupYarnEnvironment = do
copyDirectory damlTypes "daml-types"
writeRootPackageJson Nothing ["daml2ts"]
writeRootPackageJson Nothing ["daml2js"]
buildProject :: [String] -> IO ()
buildProject args = callProcessSilent damlc (["build"] ++ args)
daml2tsProject :: [FilePath] -> FilePath -> IO ()
daml2tsProject dars outDir = callProcessSilent daml2ts $ dars ++ ["-o", outDir]
daml2jsProject :: [FilePath] -> FilePath -> IO ()
daml2jsProject dars outDir = callProcessSilent daml2js $ dars ++ ["-o", outDir]
writeDamlYaml :: String -> [String] -> [String] -> Maybe LF.Version -> IO ()
writeDamlYaml mainPackageName exposedModules dependencies mbLfVersion =

View File

@ -1,6 +1,6 @@
-- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0
module DA.Test.Daml2TsUtils (writeRootPackageJson) where
module DA.Test.Daml2jsUtils (writeRootPackageJson) where
import qualified Data.Text.Extended as T
import qualified Data.ByteString.Lazy as BSL
@ -9,7 +9,7 @@ import Data.Aeson
import System.FilePath
-- The need for this utility comes up in at least the assistant
-- integration and daml2ts tests.
-- integration and daml2js tests.
writeRootPackageJson :: Maybe FilePath -> [String] -> IO ()
writeRootPackageJson dir workspaces =
BSL.writeFile (maybe "package.json" (</> "package.json") dir) $ encode $

View File

@ -6,7 +6,7 @@
"license": "Apache-2.0",
"dependencies": {
"@daml/ledger": "file:../daml-ledger",
"@daml.js/build-and-lint-1.0.0": "file:../daml2ts/build-and-lint-1.0.0",
"@daml.js/build-and-lint-1.0.0": "file:../daml2js/build-and-lint-1.0.0",
"p-event": "^4.1.0"
},
"scripts": {

View File

@ -1,6 +1,6 @@
{
"private": true,
"workspaces": ["daml2ts"],
"workspaces": ["daml2js"],
"resolutions": {
"@daml/types": "file:daml-types"
}

View File

@ -8,4 +8,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
DAR=$DIR/daml/.daml/dist/daml-1.0.0.dar
GEN=$DIR/ts/generated/src/daml
ghcid --command "da-ghci //:daml2ts" --reload $DAR --test ":main -o $GEN $DAR"
ghcid --command "da-ghci //:daml2js" --reload $DAR --test ":main -o $GEN $DAR"

View File

@ -20,7 +20,7 @@ def sdk_tarball(name, version):
"//compiler/damlc:damlc-dist",
"//compiler/daml-extension:vsix",
"//daml-assistant/daml-helper:daml-helper-dist",
"//language-support/ts/codegen:daml2ts-dist",
"//language-support/ts/codegen:daml2js-dist",
"//templates:templates-tarball.tar.gz",
"//triggers/daml:daml-trigger-dars",
"//daml-script/daml:daml-script-dars",
@ -54,8 +54,8 @@ def sdk_tarball(name, version):
mkdir -p $$OUT/daml-helper
tar xf $(location //daml-assistant/daml-helper:daml-helper-dist) --strip-components=1 -C $$OUT/daml-helper
mkdir -p $$OUT/daml2ts
tar xf $(location //language-support/ts/codegen:daml2ts-dist) --strip-components=1 -C $$OUT/daml2ts
mkdir -p $$OUT/daml2js
tar xf $(location //language-support/ts/codegen:daml2js-dist) --strip-components=1 -C $$OUT/daml2js
mkdir -p $$OUT/studio
cp $(location //compiler/daml-extension:vsix) $$OUT/studio/daml-bundled.vsix