-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate management canister Candid file (#265)
* Generate management canister Candid file * Adjust test description * Update package-lock.json
- Loading branch information
Showing
6 changed files
with
51 additions
and
231 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const https = require('https'); | ||
|
||
const generatedDirectory = path.join(__dirname, '../src/generated'); | ||
if (!fs.existsSync(generatedDirectory)) { | ||
fs.mkdirSync(generatedDirectory); | ||
} | ||
|
||
https | ||
.get( | ||
'https://raw.githubusercontent.com/dfinity/interface-spec/master/spec/_attachments/ic.did', | ||
(response) => { | ||
if (response.statusCode !== 200) { | ||
throw new Error( | ||
`HTTP ${response.statusCode}: ${response.statusMessage}`, | ||
); | ||
} | ||
const data = []; | ||
response.on('data', (chunk) => data.push(chunk)); | ||
response.on('end', () => { | ||
fs.writeFile( | ||
path.join(generatedDirectory, 'aaaaa-aa.did.ts'), | ||
`export default \`${data.join('')}\`;\n`, | ||
(err) => { | ||
if (err) { | ||
throw err; | ||
} | ||
}, | ||
); | ||
}); | ||
}, | ||
) | ||
.on('error', (err) => { | ||
console.error( | ||
'Error while downloading management canister Candid file:', | ||
); | ||
throw err; | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import icCandid from '../generated/aaaaa-aa.did'; | ||
|
||
describe('server', () => { | ||
test('generated IC Candid file has expected format', () => { | ||
expect(icCandid).toContain('service ic : {\n'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters