Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

Commit 5157d6f

Browse files
committed
patch: generate readme in new project
1 parent c03a598 commit 5157d6f

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

cli/src/init.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { preludeFiles } from "@devicescript/compiler"
1313
const MAIN = "main.ts"
1414
const GITIGNORE = ".gitignore"
1515

16-
const optionalFiles: Record<string, any> = {
16+
const optionalFiles: Record<string, Object | string> = {
1717
"tsconfig.json": {
1818
compilerOptions: {
1919
moduleResolution: "node",
@@ -43,6 +43,36 @@ const optionalFiles: Record<string, any> = {
4343
".vscode/extensions.json": {
4444
recommendations: ["esbenp.prettier-vscode"],
4545
},
46+
"README.md": `# - project name -
47+
48+
This project uses [DeviceScript](https://microsoft.github.io/devicescript/).
49+
50+
## Local/container development
51+
52+
- install node.js and dependencies
53+
54+
\`\`\`bash
55+
yarn install
56+
\`\`\`
57+
58+
- prepare TypeScript support files
59+
60+
\`\`\`bash
61+
yarn setup
62+
\`\`\`
63+
64+
- launch developer server
65+
66+
\`\`\`bash
67+
yarn watch
68+
\`\`\`
69+
70+
- navigate to devtools page (see terminal output)
71+
to use the simulators or deploy to hardware.
72+
73+
- open \`main.ts\` in your favorite TypeScript IDE and start editing.
74+
75+
`,
4676
}
4777
export interface InitOptions {
4878
force?: boolean
@@ -59,7 +89,9 @@ export default function init(options: InitOptions & CmdOptions) {
5989
debug(`write ${fn}`)
6090
const dn = dirname(fn)
6191
if (dn) ensureDirSync(dn)
62-
writeJSONSync(fn, data, { spaces })
92+
if (typeof data === "string")
93+
writeFileSync(fn, data, { encoding: "utf8" })
94+
else writeJSONSync(fn, data, { spaces })
6395
} else {
6496
debug(`skip ${fn}, already exists`)
6597
}

0 commit comments

Comments
 (0)