Skip to content

Commit 79fa634

Browse files
committed
touchups
1 parent e7678f5 commit 79fa634

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/features/creators/creationHelpers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ export async function manageCopilotInstructionsFile(
147147
const customInstructions = await fs.pathExists(customInstructionsPath);
148148
if (customInstructions) {
149149
// Append to the existing file
150-
await fs.appendFile(customInstructionsPath, instructionsText.replace('<package_name>', packageName));
150+
await fs.appendFile(customInstructionsPath, instructionsText.replace(/<package_name>/g, packageName));
151151
} else {
152152
// Create the file if it doesn't exist
153-
await fs.writeFile(customInstructionsPath, instructionsText.replace('<package_name>', packageName));
153+
await fs.writeFile(customInstructionsPath, instructionsText.replace(/<package_name>/g, packageName));
154154
}
155155
}
156156

src/features/creators/newPackageProject.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
export class NewPackageProject implements PythonProjectCreator {
1818
public readonly name = 'newPackage';
1919
public readonly displayName = 'Package';
20-
public readonly description = 'Create a package folder nested in the current workspace.';
20+
public readonly description = 'Creates a package folder in your current workspace';
2121
public readonly tooltip = new MarkdownString('Create a new Python package');
2222

2323
constructor(private readonly envManagers: EnvironmentManagers) {}
@@ -41,6 +41,16 @@ export class NewPackageProject implements PythonProjectCreator {
4141
prompt: 'What is the name of the package? (e.g. my_package)',
4242
ignoreFocusOut: true,
4343
showBackButton: true,
44+
validateInput: (value) => {
45+
// following PyPI (PEP 508) rules for package names
46+
if (!/^([a-z_]|[a-z0-9_][a-z0-9._-]*[a-z0-9_])$/i.test(value)) {
47+
return 'Invalid package name. Use only letters, numbers, underscores, hyphens, or periods. Must start and end with a letter or number.';
48+
}
49+
if (/^[-._0-9]$/i.test(value)) {
50+
return 'Single-character package names cannot be a number, hyphen, or period.';
51+
}
52+
return null;
53+
},
4454
});
4555
} catch (ex) {
4656
if (ex === QuickInputButtons.Back) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Copilot Instructions for <package_name>
22

33
- The package `<package_name>` is a Python Project located in the folder `<package_name>-folder`.
4-
- You need to call the `Get Python Environment Information` tool on the <package_name> path to get the Python executable details.
5-
- Substitute the Python executable you get from the `Get Python Environment Information` tool anywhere you see <python> in these instructions.
4+
- You need to call the `Get Python Environment Information` tool on the `<package_name>` path to get the Python executable details.
5+
- Substitute the Python executable you get from the `Get Python Environment Information` tool anywhere you see `<python>` in these instructions.
66
- Run command for `<package_name>`: `<python> -m <package_name>`
77
- Command to run tests for `<package_name>`: `<python> -m pytest <package_name>/tests`
8-
- To run an editable install for the package `<package_name>`, use the `Install Python Package` tool with the `<package_name>-folder` path and arguments ['-e', '.'].
8+
- To run an editable install for the package `<package_name>`, use the `Install Python Package` tool with the `<package_name>-folder` path and arguments `['-e', '.']`.
99
- In the workspace `launch.json` file, configurations related to this package have the prefix `<package_name>`.
1010
- The package `<package_name>` has a defined `pyproject.toml` file that you should use and keep up to date.

0 commit comments

Comments
 (0)