1 | ---
|
2 | layout: default
|
3 | ---
|
4 |
|
5 | ## Tutorial
|
6 |
|
7 | ### help
|
8 |
|
9 | You can have a quick look at the following commands.
|
10 |
|
11 | ```
|
12 | 1c help
|
13 | ```
|
14 |
|
15 | ### env
|
16 |
|
17 | Check everything you need before using 1c to build your project.
|
18 |
|
19 | ```
|
20 | 1c env
|
21 | ```
|
22 |
|
23 | ### install
|
24 |
|
25 | Add the NPM and Maven libraries you need to `package.json`.
|
26 |
|
27 | ```bash
|
28 | $ cat package.json
|
29 | {
|
30 | "dependencies": {
|
31 | "mockxhr": "^1.3.0"
|
32 | },
|
33 | "mvnDependencies": [
|
34 | "org.tinylog:tinylog:1.2"
|
35 | ]
|
36 | }
|
37 |
|
38 | $ 1c install
|
39 | npm WARN wizawu.com No repository field.
|
40 | npm WARN wizawu.com No license field.
|
41 | up to date in 0.4s
|
42 |
|
43 | BUILD SUCCESSFUL
|
44 |
|
45 | Total time: 4.019 secs
|
46 | Disassembling lib/tinylog-1.2.jar: 83 classes
|
47 | Generated lib/@types/tinylog-1.2.d.ts
|
48 | ```
|
49 |
|
50 | Now you have installed both NPM and Maven dependencies. We will only use `tinylog` in this tutorial.
|
51 |
|
52 | `tsconfig.json` will be also generated after running `1c install`. So you can import the directory to IDE (VS Code, WebStorm, etc) now.
|
53 |
|
54 | ### build
|
55 |
|
56 | Edit `main.ts` as follow.
|
57 |
|
58 | ```typescript
|
59 | const JAVA_VERSION = java.lang.System.getProperty("java.version")
|
60 | org.pmw.tinylog.Logger.info(`Java version ${JAVA_VERSION}`)
|
61 | ```
|
62 |
|
63 | Build the entry.
|
64 |
|
65 | ```bash
|
66 | $ 1c build main.ts
|
67 | ts-loader: Using typescript@2.3.4 and /home/wizawu/new/tsconfig.json
|
68 | Hash: a224cd98aa0291534c77
|
69 | Time: 6514ms
|
70 | Asset Size Chunks Chunk Names
|
71 | main.js 703 bytes 0 [emitted] main.js
|
72 | main.js.map 839 bytes 0 [emitted] main.js
|
73 | ```
|
74 |
|
75 | ### run
|
76 |
|
77 | Now you are ready to run your first program with 1c.
|
78 |
|
79 | ```bash
|
80 | $ 1c run main.js
|
81 | 2017-04-27 02:35:57 [main] jdk.nashorn.internal.scripts.Script$Recompilation.L:71()
|
82 | INFO: Java version 1.8.0_77-Debian
|
83 | ```
|