Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding to create command to support React modules #976

Merged
merged 23 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
af0170d
adding to prompt, passing more args
TanyaScales Dec 21, 2023
6b02500
add jsdoc param - remove logic for module create function
TanyaScales Jan 11, 2024
a8e4e25
updating create prompt in ATs to match new flow
TanyaScales Jan 11, 2024
82a1558
taking package version back to 5.1.1
TanyaScales Jan 12, 2024
ac056db
adding the hidden property to the internal flag
TanyaScales Jan 12, 2024
5a1a726
adding rough POC for listing and fetching react modules from a repo
TanyaScales Jan 17, 2024
e3c8672
console
TanyaScales Jan 18, 2024
72a9924
Merge branch 'master' into ts/152-JSR-module-create
TanyaScales Jan 18, 2024
9698c64
Merge branch 'ts/152-JSR-module-create' into ts/159-JSR-list-modules
TanyaScales Jan 19, 2024
58f10a2
laying out react commands to list and download react modules
TanyaScales Jan 24, 2024
d704a84
Merge branch 'master' into ts/152-JSR-module-create
TanyaScales Jan 24, 2024
8cb09ef
updating map to forEach
TanyaScales Jan 24, 2024
467716f
adding tracking to command
TanyaScales Jan 24, 2024
829f52a
- updating command to fallback to listing functionality when no name …
TanyaScales Jan 25, 2024
b0880e6
updating error catch
TanyaScales Jan 30, 2024
df8e5ff
Merge branch 'master' into ts/152-JSR-module-create
TanyaScales Feb 6, 2024
f7c50fb
Merge branch 'master' into ts/159-JSR-list-modules
TanyaScales Feb 6, 2024
4459e23
Merge branch 'ts/152-JSR-module-create' into ts/159-JSR-list-modules
TanyaScales Feb 6, 2024
3364db8
update word in lang
TanyaScales Feb 20, 2024
6846879
trying to fix tests
TanyaScales Feb 21, 2024
416707b
Merge branch 'master' into ts/152-JSR-module-create
TanyaScales Feb 21, 2024
3c59921
Merge branch 'ts/152-JSR-module-create' into ts/159-JSR-list-modules
TanyaScales Feb 21, 2024
30226e9
Merge pull request #984 from HubSpot/ts/159-JSR-list-modules
TanyaScales Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acceptance-tests/tests/create.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('hs create', () => {
it('creates a module', async () => {
await cli.execute(
['create', 'module', FOLDERS.module.name],
['label', ENTER, ENTER, 'y', ENTER]
['label', ENTER, ENTER, ENTER]
);

expect(existsSync(FOLDERS.module.folder)).toBe(true);
Expand Down
11 changes: 8 additions & 3 deletions packages/cli/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* assetType: String - Type of the asset (e.g. api-sample, react-app, template)
* name: String - Filename of the asset
* dest: String - The path specified by the user on where to create the asset
* internal: Boolean - A flag for retrieving the internal spec for the asset type
* options: Object - The options object passed to the command by Yargs
* }
*/
Expand All @@ -39,13 +40,13 @@ const SUPPORTED_ASSET_TYPES = Object.keys(assets)
.filter(t => !assets[t].hidden)
.join(', ');

exports.command = 'create <type> [name] [dest]';
exports.command = 'create <type> [name] [dest] [--internal]';
exports.describe = i18n(`${i18nKey}.describe`, {
supportedAssetTypes: SUPPORTED_ASSET_TYPES,
});

exports.handler = async options => {
let { type: assetType, name, dest } = options;
let { type: assetType, name, dest, internal: getInternalVersion } = options;

setLogLevel(options);
logDebugInfo(options);
Expand Down Expand Up @@ -73,7 +74,7 @@ exports.handler = async options => {
}

const asset = assets[assetType];
const argsToPass = { assetType, name, dest, options };
const argsToPass = { assetType, name, dest, getInternalVersion, options };
dest = argsToPass.dest = resolveLocalPath(asset.dest(argsToPass));

trackCommandUsage('create', { assetType }, getAccountId(options));
Expand Down Expand Up @@ -111,6 +112,10 @@ exports.builder = yargs => {
describe: i18n(`${i18nKey}.positionals.dest.describe`),
type: 'string',
});
yargs.option('internal', {
describe: 'Internal HubSpot version of creation command',
type: 'boolean',
});
TanyaScales marked this conversation as resolved.
Show resolved Hide resolved

return yargs;
};
5 changes: 3 additions & 2 deletions packages/cli/commands/create/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ module.exports = {

return true;
},
execute: async ({ name, dest }) => {
execute: async ({ name, dest, getInternalVersion }) => {
const moduleDefinition = await createModulePrompt();
await createModule(moduleDefinition, name, dest);

await createModule(moduleDefinition, name, dest, getInternalVersion);
},
};
1 change: 1 addition & 0 deletions packages/cli/lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ en:
selectTemplate: "Select the type of template to create"
createModulePrompt:
enterLabel: "What should the module label be?"
selectReactType: "Is this a React module?"
selectContentType: "What types of content will this module be used in?"
confirmGlobal: "Is this a global module?"
errors:
Expand Down
15 changes: 14 additions & 1 deletion packages/cli/lib/prompts/createModulePrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ const MODULE_LABEL_PROMPT = {
return true;
},
};

const REACT_TYPE_PROMPT = {
type: 'confirm',
name: 'reactType',
message: i18n(`${i18nKey}.selectReactType`),
default: false,
};

const CONTENT_TYPES_PROMPT = {
type: 'checkbox',
name: 'contentTypes',
Expand Down Expand Up @@ -44,7 +52,12 @@ const GLOBAL_PROMPT = {
};

function createModulePrompt() {
return promptUser([MODULE_LABEL_PROMPT, CONTENT_TYPES_PROMPT, GLOBAL_PROMPT]);
return promptUser([
MODULE_LABEL_PROMPT,
REACT_TYPE_PROMPT,
CONTENT_TYPES_PROMPT,
GLOBAL_PROMPT,
]);
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hubspot/cli",
"version": "5.1.1",
"version": "5.1.2",
TanyaScales marked this conversation as resolved.
Show resolved Hide resolved
"description": "CLI for working with HubSpot",
"license": "Apache-2.0",
"repository": {
Expand Down
Loading