-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add openapi stub action
- Loading branch information
Showing
7 changed files
with
219 additions
and
4 deletions.
There are no files selected for viewing
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,93 @@ | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
import { AncaDevelopment } from "../schema.js"; | ||
import { writeFolderFile } from "../utils.js"; | ||
|
||
const SRC_FILE_PATH = "./src/index.ts"; | ||
const TEST_FILE_PATH = "./test/index.test.ts"; | ||
|
||
/** | ||
* | ||
* @param development | ||
*/ | ||
function getSrcContents(development: AncaDevelopment) { | ||
return `console.log("Hello, Anca!"); // ${development.fullPath}\n`; | ||
} | ||
|
||
/** | ||
* | ||
* @param development | ||
*/ | ||
function getTestContents(development: AncaDevelopment) { | ||
return `console.log("Hello, Test Anca!"); // ${development.fullPath}\n`; | ||
} | ||
|
||
/** | ||
* | ||
* @param development | ||
*/ | ||
export async function checkNodejsSrc(development: AncaDevelopment) { | ||
if (development.state == null) { | ||
return; | ||
} | ||
const contents = development.state.files[SRC_FILE_PATH]; | ||
if (contents == null) { | ||
return false; | ||
} | ||
|
||
return contents === getSrcContents(development); | ||
} | ||
|
||
/** | ||
* | ||
* @param development | ||
*/ | ||
export async function checkNodejsTest(development: AncaDevelopment) { | ||
if (development.state == null) { | ||
return; | ||
} | ||
const contents = development.state.files[TEST_FILE_PATH]; | ||
console.log(contents); | ||
if (contents == null) { | ||
return false; | ||
} | ||
|
||
return contents === getTestContents(development); | ||
} | ||
|
||
/** | ||
* | ||
* @param development | ||
*/ | ||
export async function fixNodejsSrc(development: AncaDevelopment) { | ||
if (development.state == null) { | ||
return; | ||
} | ||
await fs.promises.mkdir(path.join(development.fullPath, "src"), { | ||
recursive: true, | ||
}); | ||
await writeFolderFile( | ||
development.fullPath, | ||
SRC_FILE_PATH, | ||
getSrcContents(development), | ||
); | ||
} | ||
|
||
/** | ||
* | ||
* @param development | ||
*/ | ||
export async function fixNodejsTest(development: AncaDevelopment) { | ||
if (development.state == null) { | ||
return; | ||
} | ||
await fs.promises.mkdir(path.join(development.fullPath, "test"), { | ||
recursive: true, | ||
}); | ||
await writeFolderFile( | ||
development.fullPath, | ||
TEST_FILE_PATH, | ||
getTestContents(development), | ||
); | ||
} |
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,43 @@ | ||
import { AncaDevelopment } from "../schema.js"; | ||
import { writeFolderFile } from "../utils.js"; | ||
|
||
const FILE_PATH = "openapi.json"; | ||
|
||
/** | ||
* | ||
* @param development | ||
*/ | ||
function getContents(development: AncaDevelopment) { | ||
return "json content of openapi " + development.fullPath; | ||
} | ||
|
||
/** | ||
* | ||
* @param development | ||
*/ | ||
export async function checkOpenapiJson(development: AncaDevelopment) { | ||
if (development.state == null) { | ||
return; | ||
} | ||
const contents = development.state.files[FILE_PATH]; | ||
if (contents == null) { | ||
return false; | ||
} | ||
|
||
return contents === getContents(development); | ||
} | ||
|
||
/** | ||
* | ||
* @param development | ||
*/ | ||
export async function fixOpenapiJson(development: AncaDevelopment) { | ||
if (development.state == null) { | ||
return; | ||
} | ||
await writeFolderFile( | ||
development.fullPath, | ||
FILE_PATH, | ||
getContents(development), | ||
); | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// This file was generated by Cinnabar Meta. Do not edit. | ||
|
||
export const CINNABAR_PROJECT_TIMESTAMP = 1725439329; | ||
export const CINNABAR_PROJECT_VERSION = "0.1.0-dev.2+next.20240904_084209"; | ||
export const CINNABAR_PROJECT_TIMESTAMP = 1725457151; | ||
export const CINNABAR_PROJECT_VERSION = "0.1.0-dev.2+next.20240904_133911"; |
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
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