Skip to content

Commit 3b06f2e

Browse files
committed
dynamically populate sample list + update readme
1 parent 67792bd commit 3b06f2e

5 files changed

Lines changed: 31 additions & 8 deletions

File tree

Foyfile.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ var nbgv = require('nerdbank-gitversioning')
44

55
setGlobalOptions({ loading: false })
66

7+
// build a list of all the samples from the samples directory
8+
const sampleDir = path.posix.join(__dirname, "samples")
9+
const samples = fs.readdirSync(sampleDir)
10+
.filter(x => !x.startsWith("_"))
11+
.map(x => path.join(sampleDir, x))
12+
.filter(x => fs.statSync(x).isDirectory())
13+
.map(x => path.basename(x))
14+
15+
716
task('setversion', async ctx => {
817
const compilerPath = path.join(__dirname, "packages", "compiler")
918
const fxPath = path.join(__dirname, "packages", "framework")
@@ -24,13 +33,6 @@ task('clean', async ctx => {
2433
await ctx.exec('git clean -dxf', { cwd: path.join(__dirname, "samples") });
2534
})
2635

27-
const samples = [
28-
"helloworld",
29-
"nep11token",
30-
"nep17token",
31-
// "registrar"
32-
];
33-
3436
async function buildSample(ctx, sample) {
3537
const cwd = path.join(__dirname, "samples", sample);
3638
const compilerPath = path.posix.join(__dirname, "packages/compiler/lib/main.js").replace(/\\/g, '/');

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# neo-devpack-ts
22

3-
*under active development*
3+
> Note, this project is under active development. It is not yet packaged as a stand alone tool.
4+
> If you wish to try it with your own contract, please see the [Samples](#samples) section below.
45
56
## Requirements
67

@@ -14,4 +15,24 @@
1415
* `npm run build`: compiles the devpack
1516
* `npm run clean`: cleans the build output
1617
* `npm run samples`: compiles the devpack and builds the sample contracts
18+
* `npx foy <sample name>`: builds the specified sample contract and runs the associated express.batch file if available
19+
20+
## Samples
21+
22+
The `foy` task runner dynamically generates the samples to build from the contents of the `samples` directory.
23+
Any subdirectory of `samples` that doesn't start with an underscore is considered a sample.
24+
Each sample directory must contain a contract `.ts` file matching the name of the directory.
25+
If the sample directory contains an `express.batch` file, it will be run automatically after the contract is built.
26+
27+
### Hello World
28+
29+
Simple contract that stores a byte string in contract storage and returns it when called.
30+
31+
### Tank NEP-17 Token
32+
33+
Implements a sample [NEP-17](https://github.com/neo-project/proposals/blob/master/nep-17.mediawiki) fungible token contract
34+
35+
### Hovercraft NEP-11 Token
36+
37+
Implements a sample [NEP-11](https://github.com/neo-project/proposals/blob/master/nep-11.mediawiki) non fungible token contract
1738

0 commit comments

Comments
 (0)