Skip to content

Commit

Permalink
chore(vue): temp add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed Sep 12, 2023
1 parent 7935cb7 commit 26bb9e3
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/create-nx-workspace/bin/create-nx-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ async function normalizeArgsMiddleware(
argv.stack = await determineStack(argv);
const presetOptions = await determinePresetOptions(argv);
Object.assign(argv, presetOptions);
console.log('Katerina', 6, { argv }, presetOptions);
}

const packageManager = await determinePackageManager(argv);
Expand All @@ -312,7 +313,7 @@ async function normalizeArgsMiddleware(
ci,
});
} catch (e) {
console.error(e);
console.error('KATERINA ERRRR', e);
process.exit(1);
}
}
Expand Down Expand Up @@ -438,6 +439,7 @@ async function determinePresetOptions(
case 'angular':
return determineAngularOptions(parsedArgs);
case 'vue':
console.log('Katerina', 0);
return determineVueOptions(parsedArgs);
case 'node':
return determineNodeOptions(parsedArgs);
Expand Down Expand Up @@ -617,6 +619,8 @@ async function determineVueOptions(
let appName: string;
let e2eTestRunner: undefined | 'none' | 'cypress' | 'playwright' = undefined;

console.log('Katerina', 1);

if (parsedArgs.preset && parsedArgs.preset !== Preset.Vue) {
preset = parsedArgs.preset;
if (preset === Preset.VueStandalone || preset === Preset.VueMonorepo) {
Expand All @@ -639,8 +643,10 @@ async function determineVueOptions(
preset = Preset.VueMonorepo;
}
}
console.log('Katerina', 2);

e2eTestRunner = await determineE2eTestRunner(parsedArgs);
console.log('Katerina', 3);

if (parsedArgs.style) {
style = parsedArgs.style;
Expand Down Expand Up @@ -673,6 +679,8 @@ async function determineVueOptions(
]);
style = reply.style;
}
console.log('Katerina', 4);
console.log('Katerina', 5, { preset, style, appName, e2eTestRunner });

return { preset, style, appName, e2eTestRunner };
}
Expand Down
2 changes: 2 additions & 0 deletions packages/create-nx-workspace/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
import { commandsObject } from './create-nx-workspace';

commandsObject.argv;

console.log('KATERINA COMMANDS commandsObject', commandsObject);
3 changes: 3 additions & 0 deletions packages/create-nx-workspace/src/create-empty-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ export async function createEmptyWorkspace<T extends CreateWorkspaceOptions>(

try {
const fullCommand = `${pmc.exec} nx ${command} --nxWorkspaceRoot=${nxWorkspaceRoot}`;
console.log('Katerina fullCommand', 7, fullCommand);
console.log('Katerina tmpDir', 8, tmpDir);
await execAndWait(fullCommand, tmpDir);

workspaceSetupSpinner.succeed(
`Successfully created the workspace: ${directory}.`
);
} catch (e) {
console.log('KATERINA MORE EERRRR', e);
workspaceSetupSpinner.fail();
if (e instanceof Error) {
output.error({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function execAndWait(command: string, cwd: string) {
{ cwd, env: { ...process.env, NX_DAEMON: 'false' } },
(error, stdout, stderr) => {
if (error) {
console.log('KAATERINA SOME ERRR', 50, error);
const logFile = join(cwd, 'error.log');
writeFileSync(logFile, `${stdout}\n${stderr}`);
const message = stderr && stderr.trim().length ? stderr : stdout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,136 @@ Nx comes with local caching already built-in (check your \`nx.json\`). On CI you
"
`;

exports[`@nx/workspace:generateWorkspaceFiles README.md should be created for VueMonorepo preset 1`] = `
"# Proj

<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>

✨ **This workspace has been generated by [Nx, a Smart, fast and extensible build system.](https://nx.dev)** ✨

## Start the app

To start the development server run \`nx serve app1\`. Open your browser and navigate to http://localhost:4200/. Happy coding!

## Generate code

If you happen to use Nx plugins, you can leverage code generators that might come with it.

Run \`nx list\` to get a list of available plugins and whether they have generators. Then run \`nx list <plugin-name>\` to see what generators are available.

Learn more about [Nx generators on the docs](https://nx.dev/plugin-features/use-code-generators).

## Running tasks

To execute tasks with Nx use the following syntax:

\`\`\`
nx <target> <project> <...options>
\`\`\`

You can also run multiple targets:

\`\`\`
nx run-many -t <target1> <target2>
\`\`\`

..or add \`-p\` to filter specific projects

\`\`\`
nx run-many -t <target1> <target2> -p <proj1> <proj2>
\`\`\`

Targets can be defined in the \`package.json\` or \`projects.json\`. Learn more [in the docs](https://nx.dev/core-features/run-tasks).

## Want better Editor Integration?

Have a look at the [Nx Console extensions](https://nx.dev/nx-console). It provides autocomplete support, a UI for exploring and running tasks & generators, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users.

## Ready to deploy?

Just run \`nx build demoapp\` to build the application. The build artifacts will be stored in the \`dist/\` directory, ready to be deployed.

## Set up CI!

Nx comes with local caching already built-in (check your \`nx.json\`). On CI you might want to go a step further.

- [Set up remote caching](https://nx.dev/core-features/share-your-cache)
- [Set up task distribution across multiple machines](https://nx.dev/core-features/distribute-task-execution)
- [Learn more how to setup CI](https://nx.dev/recipes/ci)

## Connect with us!

- [Join the community](https://nx.dev/community)
- [Subscribe to the Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
- [Follow us on Twitter](https://twitter.com/nxdevtools)
"
`;

exports[`@nx/workspace:generateWorkspaceFiles README.md should be created for VueStandalone preset 1`] = `
"# Proj

<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>

✨ **This workspace has been generated by [Nx, a Smart, fast and extensible build system.](https://nx.dev)** ✨

## Start the app

To start the development server run \`nx serve app1\`. Open your browser and navigate to http://localhost:4200/. Happy coding!

## Generate code

If you happen to use Nx plugins, you can leverage code generators that might come with it.

Run \`nx list\` to get a list of available plugins and whether they have generators. Then run \`nx list <plugin-name>\` to see what generators are available.

Learn more about [Nx generators on the docs](https://nx.dev/plugin-features/use-code-generators).

## Running tasks

To execute tasks with Nx use the following syntax:

\`\`\`
nx <target> <project> <...options>
\`\`\`

You can also run multiple targets:

\`\`\`
nx run-many -t <target1> <target2>
\`\`\`

..or add \`-p\` to filter specific projects

\`\`\`
nx run-many -t <target1> <target2> -p <proj1> <proj2>
\`\`\`

Targets can be defined in the \`package.json\` or \`projects.json\`. Learn more [in the docs](https://nx.dev/core-features/run-tasks).

## Want better Editor Integration?

Have a look at the [Nx Console extensions](https://nx.dev/nx-console). It provides autocomplete support, a UI for exploring and running tasks & generators, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users.

## Ready to deploy?

Just run \`nx build demoapp\` to build the application. The build artifacts will be stored in the \`dist/\` directory, ready to be deployed.

## Set up CI!

Nx comes with local caching already built-in (check your \`nx.json\`). On CI you might want to go a step further.

- [Set up remote caching](https://nx.dev/core-features/share-your-cache)
- [Set up task distribution across multiple machines](https://nx.dev/core-features/distribute-task-execution)
- [Learn more how to setup CI](https://nx.dev/recipes/ci)

## Connect with us!

- [Join the community](https://nx.dev/community)
- [Subscribe to the Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
- [Follow us on Twitter](https://twitter.com/nxdevtools)
"
`;

exports[`@nx/workspace:generateWorkspaceFiles README.md should be created for WebComponents preset 1`] = `
"# Proj

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function generateWorkspaceFiles(
tree.write(join(options.directory, 'yarn.lock'), '');
}
}
console.log('Katerina', 12);
setPresetProperty(tree, options);
addNpmScripts(tree, options);
setUpWorkspacesInPackageJson(tree, options);
Expand Down
5 changes: 5 additions & 0 deletions packages/workspace/src/generators/new/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,19 @@ export async function newGenerator(tree: Tree, opts: Schema) {
const options = normalizeOptions(opts);
validateOptions(options, tree);

console.log('Katerina', 11);

await generateWorkspaceFiles(tree, { ...options, nxCloud: undefined } as any);
console.log('Katerina', 13);

addPresetDependencies(tree, options);
console.log('Katerina', 14);

addCloudDependencies(tree, options);

return async () => {
const pmc = getPackageManagerCommand(options.packageManager);
console.log('Katerina', 16);
if (pmc.preInstall) {
execSync(pmc.preInstall, {
cwd: joinPathFragments(tree.root, options.directory),
Expand Down
2 changes: 2 additions & 0 deletions packages/workspace/src/generators/preset/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ async function createPreset(tree: Tree, options: Schema) {
unitTestRunner: options.bundler === 'vite' ? 'vitest' : 'jest',
});
} else if (options.preset === Preset.VueMonorepo) {
console.log('HELLO KATERINA PRESET VueMonorepo');
const { applicationGenerator: vueApplicationGenerator } = require('@nx' +
'/vue');

Expand All @@ -89,6 +90,7 @@ async function createPreset(tree: Tree, options: Schema) {
e2eTestRunner: options.e2eTestRunner ?? 'cypress',
});
} else if (options.preset === Preset.VueStandalone) {
console.log('HELLO KATERINA PRESET VueStandalone');
const { applicationGenerator: vueApplicationGenerator } = require('@nx' +
'/vue');

Expand Down

0 comments on commit 26bb9e3

Please sign in to comment.