Skip to content

Commit

Permalink
Sync with Cookiecutter template
Browse files Browse the repository at this point in the history
  • Loading branch information
claui committed Sep 10, 2024
1 parent 9fc920d commit 5fa4c53
Show file tree
Hide file tree
Showing 41 changed files with 3,854 additions and 990 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ indent_size = 2
indent_size = 2
trim_trailing_whitespace = false

[*.ts]
[*.{mjs,ts}]
indent_size = 2

[*.yml]
[*.{yaml,yml}]
indent_size = 2
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@

*.json text eol=lf
*.md text eol=lf
*.mjs text eol=lf
*.ts text eol=lf
*.txt text eol=lf
*.yaml text eol=lf
*.yml text eol=lf

# No need to diff or patch these
/.yarn/plugins/** binary
/.yarn/releases/*.cjs binary
/.yarn/sdks/** binary
/.yarn/plugins/** binary
27 changes: 27 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Run unit tests

on: [push]

jobs:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2

- name: Use specified Node.js version
uses: actions/setup-node@v2
with:
node-version-file: .nvmrc

- name: Install dependencies
run: yarn install

- name: Compile
run: yarn compile

- name: Run linter
run: yarn lint

- name: Run unit tests
run: yarn test
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/extension/build/
/extension/dist/
/extension/types/
/extension/work/
/.pnp.*
/.yarn/*
!/.yarn/patches/
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/gallium
lts/hydrogen
60 changes: 60 additions & 0 deletions .redport/cookiecutter_replay/cookiecutter-vscode-extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"cookiecutter": {
"extension_display_name": "Packaging",
"extension_slug": "packaging",
"project_slug": "vscode-packaging2",
"extension_description": "",
"extension_license": "Apache-2.0",
"vscode_engine_min_version_tuple": "1.92",
"contribute_language": "y",
"first_language_display_name": "PKGBUILD (AUR)",
"first_language_slug": "aur-pkgbuild",
"first_language_filename_pattern": "PKGBUILD",
"first_language_scope_group": "source",
"dedicated_library_workspace": "y",
"author_full_name": "Claudia Pellegrino",
"copyright_holder_full_name": "Claudia Pellegrino",
"publish_on_visual_studio_marketplace": "y",
"marketplace_publisher_id": "claui",
"github_username": "claui",
"install_dependencies_now": "y",
"_copy_without_render": [
".redport/patches/*.patch"
],
"_extensions": [
"local_extensions.CustomFunctionsExtension",
"local_extensions.CustomGlobalsExtension"
],
"_license_filename": "",
"_template": "vscode",
"_output_dir": "REDACTED",
"_repo_dir": "REDACTED",
"_checkout": null
},
"_cookiecutter": {
"extension_display_name": "",
"extension_slug": "{{ cookiecutter.extension_display_name.lower().replace(' ', '-').replace('_', '-') }}",
"project_slug": "vscode-{{ cookiecutter.extension_slug }}",
"extension_description": "",
"extension_license": [
"Apache-2.0",
"Proprietary"
],
"vscode_engine_min_version_tuple": "1.92",
"contribute_language": "y",
"first_language_display_name": "{{ cookiecutter.extension_display_name }}",
"first_language_slug": "{{ cookiecutter.first_language_display_name.lower().replace(' ', '-').replace('_', '-') }}",
"first_language_filename_pattern": "*.{{ cookiecutter.first_language_slug }}",
"first_language_scope_group": [
"source",
"text"
],
"dedicated_library_workspace": "y",
"author_full_name": "Claudia Pellegrino",
"copyright_holder_full_name": "{{ cookiecutter.author_full_name }}",
"publish_on_visual_studio_marketplace": "y",
"marketplace_publisher_id": "",
"github_username": "claui",
"install_dependencies_now": "y"
}
}
14 changes: 14 additions & 0 deletions .redport/manifest.rpt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"upstream": {
"type": "cookiecutter-template",
"source": "https://github.com/claui/cookiecutter-vscode-extension.git",
"commit": "783ab0e6758909b9c511edf59d0fec89fcf0093e",
"replay": "cookiecutter_replay/cookiecutter-vscode-extension.json",
"patches": [
"patches/disable-install-step.patch"
],
"nextPatches": [
"patches/disable-install-step.patch"
]
}
}
90 changes: 90 additions & 0 deletions .redport/patches/disable-install-step.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py
index cd50f86..50c8cb4 100644
--- a/hooks/post_gen_project.py
+++ b/hooks/post_gen_project.py
@@ -1,85 +1,3 @@
-import logging
-import os
import shutil
-import subprocess
-import sys
-
-from cookiecutter.config import get_user_config
-
-logger = logging.getLogger(__name__)
-
-logger.info('Saving replay file for redport')
-config_dict = get_user_config()
-template_name = '{{ cookiecutter._repo_dir.split('/')[-1] }}'
-target_replay_path = Path('.redport') / 'cookiecutter_replay'
-target_replay_path.mkdir(exist_ok=True)
-shutil.copy(
- (PurePath(config_dict['replay_dir']) / template_name).with_suffix('.json'),
- target_replay_path,
-)

shutil.rmtree('licenses')
-
-{%- if cookiecutter.contribute_language == "n" %}
-shutil.rmtree('extension/examples')
-os.remove('extension/share/language/{{ cookiecutter.first_language_slug }}.tmLanguage.json')
-os.remove('extension/share/language/language-configuration.json')
-{%- endif %}
-
-{%- if cookiecutter.dedicated_library_workspace == "n" %}
-shutil.rmtree('./{{ cookiecutter.extension_slug }}')
-{%- endif %}
-
-git_commands = [
- 'git init -q',
- 'git add .',
- {%- if cookiecutter.contribute_language == "y" %}
- 'git reset -q extension/examples extension/share/language',
- 'git add -N extension/examples extension/share/language',
- {%- endif %}
- 'git reset -q extension/README.md',
- 'git add -N extension/README.md',
- {%- if cookiecutter.dedicated_library_workspace == "y" %}
- 'git reset -q {{ cookiecutter.extension_slug }}/src {{ cookiecutter.extension_slug }}/test',
- 'git add -N {{ cookiecutter.extension_slug }}/src {{ cookiecutter.extension_slug }}/test',
- {%- endif %}
-]
-
-for git_command in git_commands:
- subprocess.run(
- git_command, check=True, shell=True, stdout=sys.stderr,
- )
-
-{%- if cookiecutter.install_dependencies_now == "y" %}
-def sysexit_formatted(message: str) -> None:
- width = max((len(line) for line in message))
- print('', width * '-', *message, width * '-',
- file=sys.stderr, sep='\n')
- sys.exit()
-
-install_commands = [
- 'yarn init -2',
- 'git checkout package.json',
- 'yarn set version 4',
- 'yarn plugin import https://go.mskelton.dev/yarn-outdated/v4',
- 'yarn install',
- 'yarn clean-install',
- 'git add .yarn .yarnrc.yml package.json yarn.lock',
-]
-
-try:
- for install_command in install_commands:
- subprocess.run(
- install_command, check=True, shell=True, stdout=sys.stderr,
- )
-except subprocess.CalledProcessError as e:
- sysexit_formatted([
- f'Shell command failed with exit code {e.returncode}.',
- 'Go to the {{ cookiecutter.project_slug }}'
- ' directory and re-run:',
- *[
- f' {command}'
- for command in ['nvm use'] + install_commands
- ],
- ])
-{%- endif %}
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dbaeumer.vscode-eslint",
"editorconfig.editorconfig",
"henrynguyen5-vsc.vsc-nvm",
"orta.vscode-jest",
"redhat.vscode-yaml"
]
}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/extension"
"--extensionDevelopmentPath=${workspaceFolder}/extension/build"
],
"outFiles": [
"${workspaceFolder}/extension/build/**/*.js",
Expand Down
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
"eslint.format.enable": true,
"eslint.nodePath": ".yarn/sdks",
"files.exclude": {
"**/.git": true
"**/.git": true,
"**/packaging/lib": true
},
"jest.jestCommandLine": "if ! type nvm > /dev/null && [ \"${NVM_DIR}\" ] && [ -s \"${NVM_DIR}/nvm.sh\" ]; then . \"${NVM_DIR}/nvm.sh\"; nvm use; fi; node --version && yarn test",
"json.schemas": [
{
"fileMatch": [
Expand All @@ -41,7 +43,11 @@
"search.exclude": {
"/extension/build": true,
"/extension/dist": true,
"/extension/types": true,
"/extension/work": true,
"/packaging/build": true,
"/packaging/dist": true,
"/packaging/types": true,
"**/.yarn": true,
"**/.pnp.*": true
},
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "Compile",
"type": "shell",
"command": "yarn compile",
"command": "if ! type nvm > /dev/null && [ \"${NVM_DIR}\" ] && [ -s \"${NVM_DIR}/nvm.sh\" ]; then . \"${NVM_DIR}/nvm.sh\"; nvm use; fi; node --version && yarn compile",
"args": [],
"problemMatcher": [
"$tsc"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/out/main.js b/out/main.js
index 8c330a58e9026b908515dc7f8e2a50242b089de1..cd3f2d7e4c5e34a2604fec7a3bd73548eed5fbef 100644
index 652b1fa7c6ec4ee91646cececcb7b4371ac120d5..6f5bdaef2ccb42132df0521537eb1479b7eb31bd 100644
--- a/out/main.js
+++ b/out/main.js
@@ -77,6 +77,7 @@ module.exports = function (argv) {
Expand All @@ -10,28 +10,29 @@ index 8c330a58e9026b908515dc7f8e2a50242b089de1..cd3f2d7e4c5e34a2604fec7a3bd73548
.option('--yarn', 'Use yarn instead of npm (default inferred from presence of yarn.lock or .yarnrc)')
.option('--no-yarn', 'Use npm instead of yarn (default inferred from lack of yarn.lock or .yarnrc)')
.option('--packagedDependencies <path>', 'Select packages that should be published only (includes dependencies)', (val, all) => (all ? all.concat(val) : [val]), undefined)
@@ -84,13 +85,14 @@ module.exports = function (argv) {
@@ -84,7 +85,7 @@ module.exports = function (argv) {
// default must remain undefined for dependencies or we will fail to load defaults from package.json
.option('--dependencies', 'Enable dependency detection via npm or yarn', undefined)
.option('--no-dependencies', 'Disable dependency detection via npm or yarn', undefined)
- .action(({ yarn, packagedDependencies, ignoreFile, dependencies }) => main((0, package_1.ls)({ useYarn: yarn, packagedDependencies, ignoreFile, dependencies })));
+ .action(({ cwd, yarn, packagedDependencies, ignoreFile, dependencies }) => main((0, package_1.ls)({ cwd, useYarn: yarn, packagedDependencies, ignoreFile, dependencies })));
commander_1.default
.command('package [version]')
.description('Packages an extension')
.alias('pack')
@@ -92,6 +93,7 @@ module.exports = function (argv) {
.option('-o, --out <path>', 'Output .vsix extension file to <path> location (defaults to <name>-<version>.vsix)')
.option('-t, --target <target>', `Target architecture. Valid targets: ${ValidTargets}`)
.option('-m, --message <commit message>', 'Commit message used when calling `npm version`.')
+ .option('-C, --cwd <directory>', 'Start in <directory> as the current working directory.')
.option('--no-git-tag-version', 'Do not create a version commit and tag when calling `npm version`. Valid only when [version] is provided.')
.option('--no-update-package-json', 'Do not update `package.json`. Valid only when [version] is provided.')
.option('--githubBranch <branch>', 'The GitHub branch used to infer relative links in README.md. Can be overridden by --baseContentUrl and --baseImagesUrl.')
@@ -109,11 +111,12 @@ module.exports = function (argv) {
.option('--pre-release', 'Mark this package as a pre-release')
@@ -111,11 +113,12 @@ module.exports = function (argv) {
.option('--allow-star-activation', 'Allow using * in activation events')
.option('--allow-missing-repository', 'Allow missing a repository URL in package.json')
- .action((version, { out, target, message, gitTagVersion, updatePackageJson, githubBranch, gitlabBranch, rewriteRelativeLinks, baseContentUrl, baseImagesUrl, yarn, ignoreFile, gitHubIssueLinking, gitLabIssueLinking, dependencies, preRelease, allowStarActivation, allowMissingRepository, }) => main((0, package_1.packageCommand)({
+ .action((version, { out, target, message, cwd, gitTagVersion, updatePackageJson, githubBranch, gitlabBranch, rewriteRelativeLinks, baseContentUrl, baseImagesUrl, yarn, ignoreFile, gitHubIssueLinking, gitLabIssueLinking, dependencies, preRelease, allowStarActivation, allowMissingRepository, }) => main((0, package_1.packageCommand)({
.option('--skip-license', 'Allow packaging without license file')
- .action((version, { out, target, message, gitTagVersion, updatePackageJson, githubBranch, gitlabBranch, rewriteRelativeLinks, baseContentUrl, baseImagesUrl, yarn, ignoreFile, gitHubIssueLinking, gitLabIssueLinking, dependencies, preRelease, allowStarActivation, allowMissingRepository, skipLicense, }) => main((0, package_1.packageCommand)({
+ .action((version, { out, target, message, cwd, gitTagVersion, updatePackageJson, githubBranch, gitlabBranch, rewriteRelativeLinks, baseContentUrl, baseImagesUrl, yarn, ignoreFile, gitHubIssueLinking, gitLabIssueLinking, dependencies, preRelease, allowStarActivation, allowMissingRepository, skipLicense, }) => main((0, package_1.packageCommand)({
packagePath: out,
version,
target,
Expand All @@ -40,20 +41,20 @@ index 8c330a58e9026b908515dc7f8e2a50242b089de1..cd3f2d7e4c5e34a2604fec7a3bd73548
gitTagVersion,
updatePackageJson,
githubBranch,
@@ -136,6 +139,7 @@ module.exports = function (argv) {
@@ -139,6 +142,7 @@ module.exports = function (argv) {
.option('-p, --pat <token>', 'Personal Access Token (defaults to VSCE_PAT environment variable)', process.env['VSCE_PAT'])
.option('-t, --target <targets...>', `Target architectures. Valid targets: ${ValidTargets}`)
.option('-m, --message <commit message>', 'Commit message used when calling `npm version`.')
+ .option('-C, --cwd <directory>', 'Start in <directory> as the current working directory.')
.option('--no-git-tag-version', 'Do not create a version commit and tag when calling `npm version`. Valid only when [version] is provided.')
.option('--no-update-package-json', 'Do not update `package.json`. Valid only when [version] is provided.')
.option('-i, --packagePath <paths...>', 'Publish the provided VSIX packages.')
@@ -154,11 +158,12 @@ module.exports = function (argv) {
.option('--allow-star-activation', 'Allow using * in activation events')
@@ -158,11 +162,12 @@ module.exports = function (argv) {
.option('--allow-missing-repository', 'Allow missing a repository URL in package.json')
.option('--skip-duplicate', 'Fail silently if version already exists on the marketplace')
- .action((version, { pat, target, message, gitTagVersion, updatePackageJson, packagePath, githubBranch, gitlabBranch, baseContentUrl, baseImagesUrl, yarn, noVerify, ignoreFile, dependencies, preRelease, allowStarActivation, allowMissingRepository, skipDuplicate, }) => main((0, publish_1.publish)({
+ .action((version, { pat, target, message, cwd, gitTagVersion, updatePackageJson, packagePath, githubBranch, gitlabBranch, baseContentUrl, baseImagesUrl, yarn, noVerify, ignoreFile, dependencies, preRelease, allowStarActivation, allowMissingRepository, skipDuplicate, }) => main((0, publish_1.publish)({
.option('--skip-license', 'Allow publishing without license file')
- .action((version, { pat, target, message, gitTagVersion, updatePackageJson, packagePath, githubBranch, gitlabBranch, baseContentUrl, baseImagesUrl, yarn, noVerify, ignoreFile, dependencies, preRelease, allowStarActivation, allowMissingRepository, skipDuplicate, skipLicense, }) => main((0, publish_1.publish)({
+ .action((version, { pat, target, message, cwd, gitTagVersion, updatePackageJson, packagePath, githubBranch, gitlabBranch, baseContentUrl, baseImagesUrl, yarn, noVerify, ignoreFile, dependencies, preRelease, allowStarActivation, allowMissingRepository, skipDuplicate, skipLicense, }) => main((0, publish_1.publish)({
pat,
version,
targets: target,
Expand Down
32 changes: 0 additions & 32 deletions .yarn/sdks/eslint/bin/eslint.js

This file was deleted.

Loading

0 comments on commit 5fa4c53

Please sign in to comment.