Skip to content

Commit

Permalink
Rename daml codegen ts to daml codegen js (digital-asset#5409)
Browse files Browse the repository at this point in the history
I've completely removed the possibility to call `daml codegen ts`. I'm
happy to add in back in a followup PR once I've seen that all our tests
pass without it existing.

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
hurryabit authored Apr 3, 2020
1 parent c496e2b commit ccfb17c
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ addName name (NCState nameMap)
in Left $ if all isVirtual badNames || isVirtual name
then diag
{ _severity = Just DsWarning
, _message = _message diag <> " This breaks `daml codegen ts` and will become an error in a future SDK version."
, _message = _message diag <> " This breaks `daml codegen js` and will become an error in a future SDK version."
}
else diag
where
Expand Down
8 changes: 4 additions & 4 deletions daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ data Command
| LedgerNavigator { flags :: LedgerFlags, remainingArguments :: [String] }
| Codegen { lang :: Lang, remainingArguments :: [String] }

data Lang = Java | Scala | TypeScript
data Lang = Java | Scala | JavaScript

commandParser :: Parser Command
commandParser = subparser $ fold
Expand Down Expand Up @@ -187,13 +187,13 @@ commandParser = subparser $ fold
[ subparser $ fold
[ command "java" $ info codegenJavaCmd forwardOptions
, command "scala" $ info codegenScalaCmd forwardOptions
, command "ts" $ info codegenTypeScriptCmd forwardOptions
, command "js" $ info codegenJavaScriptCmd forwardOptions
]
]

codegenJavaCmd = Codegen Java <$> many (argument str (metavar "ARG"))
codegenScalaCmd = Codegen Scala <$> many (argument str (metavar "ARG"))
codegenTypeScriptCmd = Codegen TypeScript <$> many (argument str (metavar "ARG"))
codegenJavaScriptCmd = Codegen JavaScript <$> many (argument str (metavar "ARG"))

ledgerCmdInfo = mconcat
[ forwardOptions
Expand Down Expand Up @@ -345,7 +345,7 @@ runCommand = \case
LedgerNavigator {..} -> runLedgerNavigator flags remainingArguments
Codegen {..} ->
case lang of
TypeScript ->
JavaScript ->
runDaml2js remainingArguments
Java ->
runJar
Expand Down
2 changes: 1 addition & 1 deletion daml-assistant/exe/DA/Daml/Assistant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ argWhitelist = S.fromList
, "navigator", "server", "console", "dump-graphql-schema", "create-config", "static", "simulated", "wallclock"
, "extractor", "prettyprint", "postgresql"
, "ledger", "list-parties", "allocate-parties", "upload-dar", "fetch-dar"
, "codegen", "java", "scala", "ts"
, "codegen", "java", "scala", "js"
, "deploy"
, "json-api"
, "trigger", "list"
Expand Down
2 changes: 1 addition & 1 deletion daml-assistant/integration-tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ da_haskell_test(
srcs = glob(["src/**/*.hs"]),
args = [
"$(location //:yarn)",
# The TS codegen test which needs this next arg is not
# The JS codegen test which needs this next arg is not
# run on Windows but we need to pass something on Windows
# to make the test harness happy. If it should be misued,
# hopefully "daml-types-not-available" will end up in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,9 @@ codegenTests codegenDir damlTypes = testGroup "daml codegen" (
[ codegenTestFor "java" Nothing
, codegenTestFor "scala" (Just "com.cookiemonster.nomnomnom")
] ++
-- The 'daml-types' NPM package is not available on Windows which
-- The '@daml/types' NPM package is not available on Windows which
-- is required by 'daml2js'.
[ codegenTestFor "ts" Nothing | not isWindows ]
[ codegenTestFor "js" Nothing | not isWindows ]
)
where
codegenTestFor :: String -> Maybe String -> TestTree
Expand All @@ -539,7 +539,7 @@ codegenTests codegenDir damlTypes = testGroup "daml codegen" (
callCommandSilent "daml build"
let darFile = projectDir </> ".daml/dist/proj-" ++ lang ++ "-0.0.1.dar"
outDir = projectDir </> "generated" </> lang
when (lang == "ts") $ do
when (lang == "js") $ do
-- This section makes
-- 'daml-types@0.0.0-SDKVERSION' available
-- to yarn.
Expand Down Expand Up @@ -576,7 +576,7 @@ createDamlAppTests = testGroup "create-daml-app" [gettingStartedGuideTest | not
let cdaDir = tmpDir </> "create-daml-app"
withCurrentDirectory cdaDir $ do
callCommandSilent "daml build"
callCommandSilent "daml codegen ts -o daml.js .daml/dist/create-daml-app-0.1.0.dar"
callCommandSilent "daml codegen js -o daml.js .daml/dist/create-daml-app-0.1.0.dar"
doesFileExist (cdaDir </> "ui" </> "build" </> "index.html") >>=
assertBool "ui/build/index.html does not yet exist" . not
withCurrentDirectory (cdaDir </> "ui") $ do
Expand Down
2 changes: 1 addition & 1 deletion docs/source/app-dev/app-arch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ corresponding typescript data definitions for the data types declared in the dep

.. code-block:: bash
daml codegen ts .daml/dist/<your-project-name.dar> -o daml.js
daml codegen js .daml/dist/<your-project-name.dar> -o daml.js
This command will generate a typescript library for each DALF in you DAR.
In ``create-daml-app``, ``ui/package.json`` refers to these libraries via the
Expand Down
4 changes: 2 additions & 2 deletions docs/source/daml2js/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Usage

``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.
In outline, the command to generate JavaScript and TypeScript typings from DAML is ``daml codegen js 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.

Here's a complete example that generates TypeScript from a project produced from the standard "skeleton" template.

Expand All @@ -31,7 +31,7 @@ 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 daml2js # Generate script bindings from the DAR
daml codegen js .daml/dist/my-proj-0.0.1.dar -o daml2js # Generate script bindings from the DAR
- On execution of these commands:

Expand Down
6 changes: 3 additions & 3 deletions docs/source/getting-started/app-architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ In order to build an application on top of DAML, we need a way to refer to our D
We do this using a DAML to TypeScript code generation tool in the DAML SDK.

To run code generation, we first need to compile the DAML model to an archive format (a ``.dar`` file).
The ``daml codegen ts`` command then takes this file as argument to produce a number of TypeScript packages in the output folder.
The ``daml codegen js`` command then takes this file as argument to produce a number of TypeScript packages in the output folder.
::

daml build
daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js
daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js

Now we have a TypeScript interface (types and companion objects) to our DAML model, which we'll use in our UI code next.

Expand Down Expand Up @@ -135,7 +135,7 @@ It uses DAML React hooks to query and update ledger state.
The ``useParty`` hook simply returns the current user as stored in the ``DamlLedger`` context.
A more interesting example is the ``allUsers`` line.
This uses the ``useStreamQuery`` hook to get all ``User`` contracts on the ledger.
(``User.User`` here is an object generated by ``daml codegen ts`` - it stores metadata of the ``User`` template defined in ``User.daml``.)
(``User.User`` here is an object generated by ``daml codegen js`` - it stores metadata of the ``User`` template defined in ``User.daml``.)
Note however that this query preserves privacy: only users that follow the current user have their contracts revealed.
This behaviour is due to the observers on the ``User`` contract being exactly in the list of users that the current user is following.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting-started/first-feature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Since we have changed our DAML code, we also need to rerun the TypeScript code g
Open a new terminal and run the following commands::

daml build
daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js
daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js

The result is an up-to-date TypeScript interface to our DAML model, in particular to the new ``Message`` template and ``SendMessage`` choice.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Once the DAR file is created you will see this message in terminal ``Created .da
Any commands starting with ``daml`` are using the :doc:`DAML Assistant </tools/assistant>`, a command line tool in the DAML SDK for building and running DAML apps.
In order to connect the UI code to this DAML, we need to run a code generation step::

daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js
daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js

Now, changing to the ``ui`` folder, use Yarn to install the project dependencies and build the app::

Expand Down
2 changes: 1 addition & 1 deletion templates/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using `daml-head` instead of `daml`.
Specifically, you should run the following in the root directory:
```
daml-head build
daml-head codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js
daml-head codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js
daml-head start
```

Expand Down
4 changes: 2 additions & 2 deletions templates/create-daml-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ First, we need to generate TypeScript code bindings for the compiled DAML model.
At the root of the repository, run
```
daml build
daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js
daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js
```
The latter command generates TypeScript packages in the `daml.js` directory.

Expand Down Expand Up @@ -87,7 +87,7 @@ DAR `create-daml-app.dar` you have just created.
To upload the UI, create a ZIP file containing all your UI assets by executing
```
daml build
daml codegen ts .daml/dist/create-daml-app-0.1.0.dar -o daml.js
daml codegen js .daml/dist/create-daml-app-0.1.0.dar -o daml.js
(cd ui && yarn build && zip -r ../create-daml-app-ui.zip build)
```
at the root of the repository. Afterwards, select the "UI Assets" tab of your
Expand Down

0 comments on commit ccfb17c

Please sign in to comment.