-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: conditionally add LICENSE and README to workspace root (#43)
- Loading branch information
Showing
4 changed files
with
63 additions
and
91 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
53 changes: 53 additions & 0 deletions
53
packages/preset-react/src/utils/generate-react-common-files.ts
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,53 @@ | ||
import { formatFiles, Tree, updateJson } from '@nx/devkit' | ||
import { commonTemplateGenerator } from '@solana-developers/preset-common' | ||
import { NormalizedReactApplicationSchema } from './normalize-react-application-schema' | ||
import { reactApplicationRunScripts } from './react-application-run-scripts' | ||
|
||
export async function generateReactCommonFiles( | ||
tree: Tree, | ||
options: NormalizedReactApplicationSchema, | ||
npmScope: string, | ||
) { | ||
updateJson(tree, 'package.json', (json) => { | ||
json.scripts = { | ||
...json.scripts, | ||
...reactApplicationRunScripts({ | ||
anchor: options.anchor, | ||
anchorName: options.anchorName, | ||
webName: options.webName, | ||
}), | ||
} | ||
return json | ||
}) | ||
|
||
if (!tree.exists('README.md')) { | ||
// Generate the readme files | ||
await commonTemplateGenerator(tree, { | ||
name: options.webName, | ||
npmScope, | ||
template: 'readme', | ||
anchor: options.anchor, | ||
anchorName: options.anchorName, | ||
webName: options.webName, | ||
directory: '.', | ||
}) | ||
} | ||
|
||
if (!tree.exists('LICENSE') && !tree.exists('LICENSE.md')) { | ||
// Generate the license files | ||
await commonTemplateGenerator(tree, { | ||
name: options.webName, | ||
npmScope, | ||
template: 'license', | ||
anchor: options.anchor, | ||
anchorName: options.anchorName, | ||
webName: options.webName, | ||
directory: '.', | ||
}) | ||
} | ||
|
||
// Format the files. | ||
if (!options.skipFormat) { | ||
await formatFiles(tree) | ||
} | ||
} |
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