Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Diéffrei Tiepo de Quadros committed Dec 16, 2022
0 parents commit 6a2936a
Show file tree
Hide file tree
Showing 26 changed files with 7,826 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
version: 2
jobs:
node-latest: &test
docker:
- image: node:latest
working_directory: ~/cli
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v1-npm-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
- v1-npm-{{checksum ".circleci/config.yml"}}
- run:
name: Install dependencies
command: yarn
- run:
name: Build plugin
command: yarn prepack
- run:
name: Testing
command: yarn test
cache:
<<: *test
steps:
- checkout
- run:
name: Install dependencies
command: yarn
- save_cache:
key: v1-npm-{{checksum ".circleci/config.yml"}}-{{checksum "yarn.lock"}}
paths:
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
- /usr/local/share/.config/yarn

workflows:
version: 2
"sf-codegen":
jobs:
- node-latest
- cache:
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

module.exports = {
parser: '@typescript-eslint/parser',
};
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*-debug.log
*-error.log
/.nyc_output
/dist
/lib
/package-lock.json
/tmp
node_modules
.idea
Binary file added .images/vscodeScreenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@salesforce/prettier-config"
48 changes: 48 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Remote",
"address": "127.0.0.1",
"port": 9229,
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
},
{
"name": "Run All Tests",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": ["--inspect", "--no-timeouts", "--colors", "test/**/*.test.ts"],
"env": {
"NODE_ENV": "development",
"SFDX_ENV": "development"
},
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "Compile"
},
{
"type": "node",
"request": "launch",
"name": "Run Current Test",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": ["--inspect", "--no-timeouts", "--colors", "${file}"],
"env": {
"NODE_ENV": "development",
"SFDX_ENV": "development"
},
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "Compile"
}
]
}
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true
},
"search.exclude": {
"**/lib": true,
"**/bin": true
}
}
57 changes: 57 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"version": "2.0.0",
"problemMatcher": "$tsc-watch",
"tasks": [
{
"label": "Compile",
"group": {
"kind": "build",
"isDefault": true
},
"command": "yarn",
"type": "shell",
"presentation": {
"focus": false,
"panel": "dedicated"
},
"args": ["run", "prepack"],
"isBackground": false,
"problemMatcher": {
"owner": "typescript",
"fileLocation": "relative",
"pattern": {
"regexp": "^(.*\\.ts):(\\d*):(\\d*)(\\s*-\\s*)(error|warning|info)\\s*(TS\\d*):\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 5,
"code": 6,
"message": 7
}
}
},
{
"label": "Lint",
"command": "yarn",
"type": "shell",
"presentation": {
"focus": false,
"panel": "dedicated"
},
"args": ["run", "lint"],
"isBackground": false,
"problemMatcher": {
"owner": "typescript",
"fileLocation": "relative",
"pattern": {
"regexp": "^(ERROR|WARNING|INFO):\\s*(.*\\.ts):(\\d*):(\\d*)(\\s*-\\s*)(.*)$",
"file": 2,
"line": 3,
"column": 4,
"severity": 1,
"message": 6
}
}
}
]
}
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
sf-codegen
==========

Utility commands to generate metadata

[![Version](https://img.shields.io/npm/v/sf-codegen.svg)](https://npmjs.org/package/sf-codegen)
[![CircleCI](https://circleci.com/gh/dieffrei/sf-codegen/tree/master.svg?style=shield)](https://circleci.com/gh/dieffrei/sf-codegen/tree/master)
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/dieffrei/sf-codegen?branch=master&svg=true)](https://ci.appveyor.com/project/heroku/sf-codegen/branch/master)
[![Greenkeeper](https://badges.greenkeeper.io/dieffrei/sf-codegen.svg)](https://greenkeeper.io/)
[![Known Vulnerabilities](https://snyk.io/test/github/dieffrei/sf-codegen/badge.svg)](https://snyk.io/test/github/dieffrei/sf-codegen)
[![Downloads/week](https://img.shields.io/npm/dw/sf-codegen.svg)](https://npmjs.org/package/sf-codegen)
[![License](https://img.shields.io/npm/l/sf-codegen.svg)](https://github.com/dieffrei/sf-codegen/blob/master/package.json)

<!-- toc -->
* [Debugging your plugin](#debugging-your-plugin)
<!-- tocstop -->
<!-- install -->
<!-- usage -->
```sh-session
$ npm install -g sf-codegen
$ sfdx COMMAND
running command...
$ sfdx (--version)
sf-codegen/0.0.1 darwin-arm64 node-v18.11.0
$ sfdx --help [COMMAND]
USAGE
$ sfdx COMMAND
...
```
<!-- usagestop -->
<!-- commands -->

<!-- commandsstop -->
<!-- debugging-your-plugin -->
# Debugging your plugin
We recommend using the Visual Studio Code (VS Code) IDE for your plugin development. Included in the `.vscode` directory of this plugin is a `launch.json` config file, which allows you to attach a debugger to the node process when running your commands.

To debug the `hello:org` command:
1. Start the inspector

If you linked your plugin to the sfdx cli, call your command with the `dev-suspend` switch:
```sh-session
$ sfdx hello:org -u myOrg@example.com --dev-suspend
```

Alternatively, to call your command using the `bin/run` script, set the `NODE_OPTIONS` environment variable to `--inspect-brk` when starting the debugger:
```sh-session
$ NODE_OPTIONS=--inspect-brk bin/run hello:org -u myOrg@example.com
```

2. Set some breakpoints in your command code
3. Click on the Debug icon in the Activity Bar on the side of VS Code to open up the Debug view.
4. In the upper left hand corner of VS Code, verify that the "Attach to Remote" launch configuration has been chosen.
5. Hit the green play button to the left of the "Attach to Remote" launch configuration window. The debugger should now be suspended on the first line of the program.
6. Hit the green play button at the top middle of VS Code (this play button will be to the right of the play button that you clicked in step #5).
<br><img src=".images/vscodeScreenshot.png" width="480" height="278"><br>
Congrats, you are debugging!
18 changes: 18 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
environment:
nodejs_version: "10"
cache:
- '%LOCALAPPDATA%\Yarn -> appveyor.yml'
- node_modules -> yarn.lock

install:
- ps: Install-Product node $env:nodejs_version x64
- yarn

build: off

build_script:
- ps: Write-Host “Prepack plugin”
- yarn prepack

test_script:
- yarn test
17 changes: 17 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node

const oclif = require('@oclif/core');

const path = require('path');
const project = path.join(__dirname, '..', 'tsconfig.json');

// In dev mode -> use ts-node and dev plugins
process.env.NODE_ENV = 'development';

require('ts-node').register({ project });

// In dev mode, always show stack traces
oclif.settings.debug = true;

// Start the CLI
oclif.run().then(oclif.flush).catch(oclif.Errors.handle);
3 changes: 3 additions & 0 deletions bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\dev" %*
5 changes: 5 additions & 0 deletions bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node

const oclif = require('@oclif/core');

oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'));
3 changes: 3 additions & 0 deletions bin/run.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

node "%~dp0\run" %*
10 changes: 10 additions & 0 deletions messages/generate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"commandDescription": "print a greeting and your org IDs",
"nameFlagDescription": "name to print",
"forceFlagDescription": "example boolean flag",
"errorNoOrgResults": "No results found for the org '%s'.",
"examples": [
"sfdx hello:org --targetusername myOrg@example.com --targetdevhubusername devhub@org.com",
"sfdx hello:org --name myname --targetusername myOrg@example.com"
]
}
72 changes: 72 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "sf-codegen",
"description": "Utility commands to generate metadata",
"version": "0.0.1",
"author": "Diéffrei Tiepo de Quadros",
"bugs": "https://github.com/dieffrei/sf-codegen/issues",
"dependencies": {
"@oclif/core": "^1",
"@salesforce/command": "^5",
"@salesforce/core": "^3",
"@salesforce/source-deploy-retrieve": "^7.5.17",
"pug": "^3.0.2",
"tslib": "^2",
"xml-formatter": "^3.1.0"
},
"devDependencies": {
"@oclif/test": "^2",
"@salesforce/ts-sinon": "^1",
"@types/chai": "^4",
"@types/mocha": "^8",
"@typescript-eslint/eslint-plugin": "^4",
"@typescript-eslint/parser": "^4",
"chai": "^4",
"eslint": "^7",
"eslint-config-prettier": "^8",
"eslint-plugin-header": "^3",
"eslint-plugin-import": "^2",
"eslint-plugin-jsdoc": "^35",
"eslint-plugin-prettier": "^3",
"eslint-plugin-typescript": "^0",
"mocha": "^9",
"nyc": "^15",
"oclif": "^3",
"prettier": "^2",
"sinon": "10.0.0",
"ts-node": "^10",
"typescript": "4"
},
"engines": {
"node": ">=14.0.0"
},
"files": [
"/lib",
"/messages",
"/npm-shrinkwrap.json",
"/oclif.manifest.json"
],
"homepage": "https://github.com/dieffrei/sf-codegen",
"keywords": [
"sfdx-plugin"
],
"license": "MIT",
"oclif": {
"commands": "./lib/commands",
"bin": "sfdx",
"topics": {
"hello": {
"description": "Commands to say hello."
}
}
},
"repository": "dieffrei/sf-codegen",
"scripts": {
"build": "tsc -p .",
"lint": "eslint src/**/*.ts test/**/*.ts",
"postpack": "rm -f oclif.manifest.json",
"posttest": "eslint src/**/*.ts test/**/*.ts",
"prepack": "rm -rf lib && tsc -b && oclif manifest && oclif readme",
"test": "nyc --extension .ts --require ts-node/register mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif readme && git add README.md"
}
}

0 comments on commit 6a2936a

Please sign in to comment.