forcedotcom / commerce-on-lightning

An SFDX Plugin to setup a B2C or B2B Store
BSD 3-Clause "New" or "Revised" License
65 stars 71 forks source link

Getting errors when running "sfdx commerce:store:create": The \"-u\" flag has been deprecated. Use \"--target-org | -o\" instead.", "The \"--apiversion\" flag has been deprecated. Use \"--api-version\" instead. #315

Open forcepulsar opened 1 month ago

forcepulsar commented 1 month ago

running the command sfdx commerce:store:create to create b2b sites I get error.

ERROR running StoreQuickstartSetup:  {
    "code": 1,
    "context": "Create",
    "commandName": "Create",
    "message": "The requested resource does not exist",
    "name": "NOT_FOUND",
    "status": 1,
    "stack": "NOT_FOUND: The requested resource does not exist\n    at HttpApi.getError (/usr/local/lib/sf/node_modules/@jsforce/jsforce-node/lib/http-api.js:278:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async /usr/local/lib/sf/node_modules/@jsforce/jsforce-node/lib/http-api.js:127:33\n    at async Connection.create (/usr/local/lib/sf/node_modules/@jsforce/jsforce-node/lib/connection.js:719:15)\n    at async Create.run (file:///usr/local/lib/sf/node_modules/@salesforce/plugin-data/lib/commands/data/create/record.js:48:24)\n    at async Create._run (/usr/local/lib/sf/node_modules/@oclif/core/lib/command.js:311:22)\n    at async Config.runCommand (/usr/local/lib/sf/node_modules/@oclif/core/lib/config/config.js:433:25)\n    at async run (/usr/local/lib/sf/node_modules/@oclif/core/lib/main.js:92:16)",
    "exitCode": 1,
    "warnings": [
        "The \"-u\" flag has been deprecated. Use \"--target-org | -o\" instead.",
        "The \"--apiversion\" flag has been deprecated. Use \"--api-version\" instead."
    ],
    "command": "sfdx force:data:record:create -u \"admin@b2b.commerce.pf\" -s \"ShippingConfigurationSet\" -v \"TargetRecordId=0ZEHy0000000KNUOA2\" --json --apiversion=57.0"
}

I managed to make it run myself by building the package locally and updating the file /src/lib/utils/sfdx/forceDataSoql.ts on line 56. Replaced the line:

appendCommonFlags(`sfdx force:data:record:create ${u} -s "${service}" -v "${value}" --json`, flags, logger),

with the following (basically hardcoding the scratch name and using sf instead of sfdx):

appendCommonFlags(`sf data create record -o <<SCRATCH ORG NICKNAME>> -s "${service}" -v "${value}" --json`, flags, logger),

Note the <> has to be hardcoded to the scratch org nickname

Then I ran the command and it worked

./bin/run commerce:store:create -n <<STORE_NAME>> -o b2b -b <<BUYER_USER_EMAIL>> -u <<ORG_USERNAME>> -v <<DEVHUB_USERNAME>> --apiversion <<API_VERSION>> 

I created a blog post about it if it helps