Skip to content

Commit 0121a89

Browse files
committed
feat: Remove Node JS scripts and babel transpiling
Also moves `src/*.js` to `js/*.js`
1 parent 892e05e commit 0121a89

23 files changed

+3
-2620
lines changed

.babelrc

-15
This file was deleted.

README.md

+2-78
Original file line numberDiff line numberDiff line change
@@ -44,86 +44,10 @@ Solved enough to pass to next round. My two solutions worked flawlessly on the f
4444

4545
After the qualification, as practice, I solved problem 3, `Cryptopangrams`, inside the `cypher.js` file. Problem 4 is also solved in `datbae.js`, very tough problem!
4646

47-
### Motivation
48-
49-
The Code Jam competition only supports nodejs `4.8.2` which creates a barrier of entry for someone who's writing modern javascript on a daily basis. We are just very much used to the syntax sugar and new functionality available to us.
50-
51-
### How does it work?
47+
### Transpiling
5248

5349
> CodeJam 2019 has enabled nodejs v11.13.0!
5450
55-
That means that transpiling is no longer vital, however, we may want special language features and babel can still provide that. For instance, pipe operators.
56-
57-
We setup babel as transpiler to help us convert our code to our target environment, that is, `4.8.2`.
58-
59-
```json
60-
{
61-
"presets": [
62-
[
63-
"@babel/preset-env",
64-
{
65-
"targets": {
66-
"node": "4.8"
67-
}
68-
}
69-
]
70-
]
71-
}
72-
```
73-
74-
We install these dependencies:
75-
76-
```json
77-
{
78-
"devDependencies": {
79-
"@babel/cli": "^7.2.3",
80-
"@babel/core": "^7.2.2",
81-
"@babel/node": "^7.2.2",
82-
"@babel/preset-env": "^7.2.3"
83-
}
84-
}
85-
```
86-
87-
And setup our scripts:
88-
89-
```json
90-
{
91-
"scripts": {
92-
"start": "babel-node",
93-
"transpile": "babel src -d build",
94-
"test": "echo \"Error: no test specified\" && exit 1"
95-
}
96-
}
97-
```
98-
99-
Just in case you want to use some new features to help you build test cases, you can use `babel-node` to the start script. Just run `yarn start <filename>`. Alternatively, `npx babel-node <filename>`.
100-
101-
We now have a project that supports babel 7+ and all of the JavaScript candy that comes with it. Furthermore, our project will rewrite our code to make sure that node `4.8.2` can run it!
102-
103-
### Approach
104-
105-
First solve the problem!
106-
107-
Second, write the code, in `src/<problemName>/index.js`.
108-
109-
Third, transpile it, `yarn transpile`. This command will actually transpile all of the files located in `src/`.
110-
111-
Now we have `4.8.2` friendly code, located in a newly created, `build/` folder.
112-
113-
You can switch to node `4.8.2` using `nvm` and give it a go.
114-
115-
This repo features a code runner, which is constantly being improved. The code runner, will take problem name as argument, look for a test file inside `tests` and a solution file inside `build/`.
116-
117-
Test files should be named `problemName.in`. I have left two, but please generate your own.
118-
119-
With the solution placed in build and your test, file you can run your solution:
120-
121-
```bash
122-
node runner <problemName/>
123-
```
124-
125-
And we can see if our solution is working as expected.
51+
To use transpiling checkout the v1 tag.
12652

127-
### Submission
12853

129-
To submit your solution, just go to Code Jam's website, navigate to the problem and select `Load File`. Then submit `build/<problemName>`, or just copy paste its contents into the Code Jam text editor.

src/crypto.js js/crypto.js

File renamed without changes.

src/datbae.js js/datbae.js

File renamed without changes.

src/expogo.js js/expogo.js

File renamed without changes.

src/foregone.js js/foregone.js

File renamed without changes.

src/indicium.js js/indicium.js

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/ownway.js js/ownway.js

File renamed without changes.

src/parenting.js js/parenting.js

File renamed without changes.

src/pascal.js js/pascal.js

File renamed without changes.

src/patterns.js js/patterns.js

File renamed without changes.

src/pylons.js js/pylons.js

File renamed without changes.

src/robot.js js/robot.js

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/vestigium.js js/vestigium.js

File renamed without changes.

package.json

-20
This file was deleted.

runner.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { performance } = require("perf_hooks");
33
const { exec, spawn } = require("child_process");
44

55
// TODO: Perhaps we could trigger a transpile process from here
6-
const [name, src = "src"] = process.argv.slice(2);
6+
const [name, src = "js"] = process.argv.slice(2);
77
const testPath = `tests/${name}.in`;
88
const target = `${src}/${name}`;
99
const expectedScriptName = `${name}.js`;

ruster.js

-67
This file was deleted.

0 commit comments

Comments
 (0)