Skip to content

Commit

Permalink
better files structure for test and script for formatting the code
Browse files Browse the repository at this point in the history
  • Loading branch information
kalwalt committed Nov 5, 2024
1 parent c0666e1 commit e322973
Show file tree
Hide file tree
Showing 14 changed files with 768 additions and 623 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check Formatting and Run Tests

on:
push:
branches:
- '**'

jobs:
check-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js version from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Install dependencies
run: npm install

- name: Check formatting
run: npm run check-format

- name: Run tests
run: npm test
10 changes: 2 additions & 8 deletions .github/workflow/build.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ name: Build and Test
on:
push:
branches:
- main
pull_request:
branches:
- main
- '**'

jobs:
build:
Expand All @@ -19,13 +16,10 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version-file: '.nvmrc'

- name: Install dependencies
run: npm install

- name: Run tests
run: npm test

- name: Build project
run: npm run build-local
14 changes: 14 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ignore artifacts:
build
coverage

# Ignore all HTML files:
*.html

# Ignore specific files:
demo/public
src/*.jpg
src/*.png
src/output
node_modules
emscripten/WebARKitLib
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 110,
"proseWrap": "preserve"
}
15 changes: 0 additions & 15 deletions NFTMarkerCreator.test.js

This file was deleted.

55 changes: 29 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Nft-Marker-Creator-App

This editor creates NFT markers for **WebARKitLib** and **ARTOOLKIT 5.x**, they are compatible with jsartoolkitNFT.js, jsartoolkit5.js, artoolkit5.js, ARnft.js and AR.js.
A Node app is provided.

Expand All @@ -14,42 +15,41 @@ This project is based on the original **NFT Marker Creator** by [Carnaux](https:

2. Install all dependencies. First run

` nvm install `
`nvm install`

it will download the node version specified in the `.nvmrc` file. You need to install nvm first if you don't have it. Then run ` nvm use 18 ` to use the node version specified in the `.nvmrc` file.
it will download the node version specified in the `.nvmrc` file. You need to install nvm first if you don't have it. Then run `nvm use 18` to use the node version specified in the `.nvmrc` file.

Then finally run

` npm install `

`npm install`

3. Put the image you want inside the `src` folder. You can just paste it or you can create a folder. e.g

- NFTmarkerCreatorAppFolder
- NFTMarkerCreator.js
- IMAGE.PNG :arrow_left:
- ...
- NFTmarkerCreatorAppFolder
- NFTMarkerCreator.js
- IMAGE.PNG :arrow_left:
- ...

or
or

- NFTmarkerCreatorAppFolder
- NFTMarkerCreator.js
- FOLDER/IMAGE.PNG :arrow_left:
- ...
- NFTmarkerCreatorAppFolder
- NFTMarkerCreator.js
- FOLDER/IMAGE.PNG :arrow_left:
- ...

4. Run it

` node NFTMarkerCreator.js -i PATH/TO/IMAGE`
` node NFTMarkerCreator.js -i PATH/TO/IMAGE`

In the end of the process an "output" folder will be created(if it does not exist) with the marker files.
In the end of the process an "output" folder will be created(if it does not exist) with the marker files.

You can use additional flags with the run command.

e.g ` node app.js -i image.png -level=4 -min_thresh=8 `
e.g `node app.js -i image.png -level=4 -min_thresh=8`

-zft
Flag for creating only the zft file
-noConf
-noConf
Disable confirmation after the confidence level
-Demo
Creates the demo configuration
Expand All @@ -61,40 +61,42 @@ e.g ` node app.js -i image.png -level=4 -min_thresh=8 `
-leveli=n
(n is an integer in range 0 (few) to 3 (many). Default 1.'
-feature_density=<feature_density>
-dpi=f:
-dpi=f:
Override embedded JPEG DPI value.
-max_dpi=<max_dpi>
-min_dpi=<min_dpi>
-background
Run in background, i.e. as daemon detached from controlling terminal. (macOS and Linux only.)
--help -h -?
--help -h -?
Display this help

5. The generated files will be on the "output" folder.

6. (OPTIONAL) You can test your marker using the demo folder!

- Just run `npm run demo`.
- Just run `npm run demo`.

- It should open a server at: http://localhost:3000/
- It should open a server at: http://localhost:3000/

If you want to create the demo configuration when you create a marker, add `-Demo` to the command parameters.
If you want to create the demo configuration when you create a marker, add `-Demo` to the command parameters.

e.g node app.js -i image.png -Demo
e.g node app.js -i image.png -Demo

## Create your NTS markers with our docker image

First, you need docker installed in your system, if you haven't, follow the Docker engine installation [instruction](https://docs.docker.com/engine/install/) .
Then inside the folder you want to run docker:

`docker run -dit --name nft-app -v "$(pwd):/src" nft-marker-creator-app:0.2.0 bash`

With the docker container generate the NFT marker:
With the docker container generate the NFT marker:

`docker exec nft-app node ../Nft-Marker-Creator-App/src/NFTMarkerCreator.js -I /src/pinball.jpg`

remember to prepend the `-I /src/<path to your image>`

## Build

Build emscripten files with docker:

docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) -e "EMSCRIPTEN=/emsdk/upstream/emscripten" emscripten/emsdk:3.1.26 npm run build-local
Expand All @@ -105,4 +107,5 @@ or better create a docker container and run the build command inside it:
docker exec emscripten-nft-marker-creator-app npm run build-local

## Planned Features
- [ ] Multi threading support to speed up the creation of the markers.

- [ ] Multi threading support to speed up the creation of the markers.
10 changes: 5 additions & 5 deletions demo/demoServer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const express = require('express');
const express = require("express");
const path = require("path");
const app = new express();

process.title = "demoNFT";

app.use("/static",express.static('public'));
app.use("/static", express.static("public"));

app.get('/', function(request, response){
response.sendFile(path.join(__dirname + '/nft.html'));
app.get("/", function (request, response) {
response.sendFile(path.join(__dirname + "/nft.html"));
});

app.listen(3000)
app.listen(3000);

console.log("Demo running at http://localhost:3000/");
2 changes: 1 addition & 1 deletion docker/BUILD-INFOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
From the main folder (NFT-Marker-Creator-App) run this command: `docker buildx build -t nft-marker-creator-app:<tag> .`
replace `<tag>` with your tag.
Then you can use the image, or upload you own version to docker hub.
Conside that you need to build the image only if you develop your own version, if you want you can use our *webarkit/nft-marker-creator-app* docker image.
Conside that you need to build the image only if you develop your own version, if you want you can use our _webarkit/nft-marker-creator-app_ docker image.
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
roots: ['<rootDir>/test'],
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'],
transform: {
'^.+\\.[tj]sx?$': 'babel-jest',
},
};
25 changes: 24 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@
"scripts": {
"test": "jest",
"build-local": "node tools/makem.js; echo Built at `date`",
"demo": "cd demo && node demoServer.js"
"demo": "cd demo && node demoServer.js",
"format": "prettier --write \"**/*.{js,json,css,md}\"",
"check-format": "prettier --check \"**/*.{js,json,css,md}\""
},
"license": "LGPL-3.0",
"devDependencies": {
"jest": "^29.7.0"
"jest": "^29.7.0",
"prettier": "^3.3.3"
}
}
Loading

0 comments on commit e322973

Please sign in to comment.